-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebserver.js
63 lines (45 loc) · 1.24 KB
/
webserver.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// /*
// *
// * webserver.js
// * Starts the js webserver for muscledb for local testing
// * Bjørn-Petter Johannessen
// * 2023
// *
// */
var fs = require('fs'),
http = require('http');
http.createServer(function (req, res) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Origin', 'http://localhost:3001/muscles')
fs.readFile(__dirname + req.url, function (err,data) {
if (err) {
res.writeHead(404);
res.end(JSON.stringify(err));
return;
}
res.writeHead(200);
res.end(data);
});
}).listen(5001);
// const express = require("express");
// const http = require("http");
// /* Config for the http server*/
// const http_config = {
// port: 5001,
// host: "localhost",
// }
// const app = express();
// const http_server = http.createServer(app);
// /*
// * Routes
// */
// app.use(express.json());
// app.use(express.static('public'));
// /* Default route + ping route */
// app.get("/", (req, res) => {
// res.status(200).json({message: "alive"});
// });
// /* Start the server */
// http_server.listen(http_config.port, http_config.host, () => {
// console.log(`Listening on ${http_config.host}:${http_config.port}`);
// });