node.js conversion

This commit is contained in:
Mikkeli Matlock
2024-02-21 15:58:29 +09:00
parent 462ca55412
commit ae746c23f4
11 changed files with 21568 additions and 16 deletions
+26
View File
@@ -0,0 +1,26 @@
const express = require('express');
const morgan = require('morgan');
const dgram = require('dgram');
const http = require('http');
const path = require('path');
const WebSocket = require('ws');
const app = express();
const httpPort = 8000;
/* ************* */
/* THE HTTP PART */
// Use morgan to log HTTP requests
app.use(morgan('dev'));
// Serve static files from 'pyry-peli' directory
// set default html to 'main.html'
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'site', 'index.html'));
})
app.use(express.static('site'));
// Start the server
app.listen(httpPort, () => {
console.log(`Server running at http://localhost:${httpPort}/`);
});
/* ************* */