-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathdev-server.js
36 lines (29 loc) · 867 Bytes
/
dev-server.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
import express from 'express';
import cors from 'cors';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
const app = express();
// Enable CORS for all routes
app.use(cors());
// Since __dirname is not defined in ES modules, you have to derive it
const __filename = fileURLToPath(
import.meta.url);
const __dirname = dirname(__filename);
// Serve static files from the 'public' directory (update the path as necessary)
app.use(express.static(__dirname));
app.get('/', (_req, res) => {
res.status(200).send(`
<!DOCTYPE html>
<body>
<h1>N8AO</h1>
<ul>
<li><a href="/example">Example</a></li>
<li><a href="/example_postprocessing">Example Postprocessing</a></li>
</ul>
</body>
`);
});
const port = process.env.PORT || 8080;
app.listen(port, () => {
console.log(`Server running on port ${port}`);
});