diff --git a/index.html b/index.html
new file mode 100644
index 0000000..156faea
--- /dev/null
+++ b/index.html
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+ Welcome file
+
+
+
+
+ Значение ножки сейчас -
+
+
+
+
diff --git a/index.js b/index.js
index a4e328a..2b95aaa 100644
--- a/index.js
+++ b/index.js
@@ -13,12 +13,12 @@
// port.on('data', function (data) {
// console.log('Data:', data.toString('UTF8'))
// })
-
+const fs = require('fs');
const http = require('node:http');
const { SerialPort } = require('serialport')
const { ReadlineParser } = require('@serialport/parser-readline')
-const port = new SerialPort({ path: '/com16', baudRate: 9600 })
+const port = new SerialPort({ path: '/com9', baudRate: 9600 })
var str = "";
@@ -33,8 +33,28 @@ parser.on('data', (data) => {
// Create a local server to receive data from
const server = http.createServer((req, res) => {
- res.writeHead(200, { 'Content-Type': 'application/json' });
- res.end(str);
+ console.log(req.url);
+if(req.url=='/'){
+ fs.readFile('index.html', (err,data) => {
+ if(err){
+ res.writeHead(404, "Not Found");
+ res.write("No file found")
+ res.end();
+ } else {
+ res.writeHead(200, {
+ 'Content-Type': 'text/html'
+ })
+ res.write(data)
+ res.end();
+ }
+ })
+ } else if(req.url=='/pin'){
+ res.writeHead(200, {'Content-Type': 'application/json'});
+ res.end(str);
+ } else{
+ res.writeHead(404, "Not Found");
+ res.end();
+ }
});
server.listen(2048);
\ No newline at end of file