srivatsavdamaraju commited on
Commit
756c3e3
·
verified ·
1 Parent(s): 69408aa

Create index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +27 -0
templates/index.html ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Real-Time Data from Arduino</title>
7
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.0.1/socket.io.min.js"></script>
8
+ </head>
9
+ <body>
10
+ <h1>Real-Time Data from Arduino</h1>
11
+ <div id="serialData">Waiting for data...</div>
12
+
13
+ <script>
14
+ // Connect to the WebSocket server
15
+ const socket = io();
16
+
17
+ // Listen for the 'response' event from the server
18
+ socket.on('response', function(data) {
19
+ // Update the webpage with the new data
20
+ document.getElementById('serialData').innerText = 'Arduino Data: ' + data.message;
21
+ });
22
+
23
+ // Send a test message (optional)
24
+ socket.emit('message', 'Hello from browser');
25
+ </script>
26
+ </body>
27
+ </html>