Skip to content
Snippets Groups Projects
Commit bd845a86 authored by Miklosimate's avatar Miklosimate
Browse files

Cleanup, comments

parent 4bcfd6cd
Branches
No related tags found
No related merge requests found
<!-- //This file was written by chatGPT (3.5) with many iterations and manual corrections. -->
<!DOCTYPE html>
<html lang="en">
<head>
......@@ -142,38 +143,6 @@
console.error('Error fetching devices:', error);
}
}
async function handleStillHereMessageAndRefresh(deviceID) {
try {
const response = await fetch(`/stillHere/${deviceID}`, {
method: 'POST',
});
const data = await response.json();
// Refresh the device list after receiving "stillHere" message
await populateDeviceList();
} catch (error) {
console.error('Error handling stillHere message:', error);
}
}
async function handleReadyMessageAndRefresh(deviceID) {
try {
const response = await fetch(`/ready/${deviceID}`, {
method: 'POST',
});
const data = await response.json();
// Refresh the device list after receiving "ready" message
await populateDeviceList();
} catch (error) {
console.error('Error handling ready message:', error);
}
}
// Populate device list on page load
populateDeviceList();
</script>
......
......@@ -28,7 +28,7 @@ app.get('/list', (req, res) => {
res.sendFile(path.join(__dirname, 'list.html'));
});
// Add route to get server info
//This function was written by chatGPT (3.5), the rest of the code and the "Write me the route for server info" input was given.
app.get('/server-info', (req, res) => {
const serverInfo = {
ip: ip.address(),
......@@ -36,8 +36,7 @@ app.get('/server-info', (req, res) => {
};
res.json(serverInfo);
});
// POST route for handling "init" messages
//This function was written by chatGPT (3.5) with many iterations and manual corrections.
app.post('/init', (req, res) => {
console.log(`Received "init" message\n`);
//If the measurement parameters has not been set yet
......@@ -67,6 +66,7 @@ app.post('/init', (req, res) => {
// POST route for checking "am-i-ok" messages
//This function was written by chatGPT (3.5) with many iterations and manual corrections.
app.post('/am-i-ok/:deviceID', (req, res) => {
const deviceID = req.params.deviceID;
let responseToSend
......@@ -85,7 +85,7 @@ app.post('/am-i-ok/:deviceID', (req, res) => {
}
console.log('Sent JSON:', responseToSend);
});
//This function was written by chatGPT (3.5) with many iterations and manual corrections.
app.post('/json/:deviceID/:f_n', (req, res) => {
const deviceID = req.params.deviceID;
const f_n = req.params.f_n;
......@@ -139,7 +139,7 @@ app.post('/ready/:deviceID', (req, res) => {
connectedDevices[deviceID].state = 'Ready';
}
});
//This function was written by chatGPT (3.5) with many iterations and manual corrections.
app.post('/stillHere/:deviceID', (req, res) => {
const deviceID = req.params.deviceID;
// Check if the device is registered
......@@ -169,7 +169,7 @@ function generateDeviceID() {
// Generate a unique device ID (you can use a more robust method if needed)
return Date.now().toString(36) + Math.random().toString(36).substr(2, 5);
}
//This function was written by chatGPT (3.5)
app.get('/get-devices', (req, res) => {
const devicesList = Object.keys(connectedDevices).map(deviceID => {
return {
......@@ -181,6 +181,7 @@ app.get('/get-devices', (req, res) => {
res.json(devicesList);
});
//This function was written by chatGPT (3.5) manual corrections was needed.
app.post('/set-server-config', (req, res) => {
// Handle the POST request to set server configuration
const { NumberOfMeasurements, Intervals, Delay } = req.body;
......
<!-- //This file was written by chatGPT (3.5) with many iterations and manual corrections. -->
<!DOCTYPE html>
<html lang="en">
<head>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment