Fix: gioco funzionante con server HTTP, menu interattivo, IA a 3 livelli

This commit is contained in:
truetype committed 2026-09-24 12:08:25 +02:00
1 parent d27d33f652
commit d1fd88b5ff
5 files changed
+352 -124

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
const http = require('http');
const fs = require('fs');
const path = require('path');
const PORT = 8091;
const ROOT = '/home/codex/giochino';
const MIME = { '.html': 'text/html', '.js': 'application/javascript', '.css': 'text/css', '.png': 'image/png' };
const server = http.createServer((req, res) => {
let filePath = path.join(ROOT, req.url === '/' ? 'index.html' : req.url);
const ext = path.extname(filePath);
fs.readFile(filePath, (err, data) => {
if (err) { res.writeHead(404); res.end('404'); return; }
res.writeHead(200, { 'Content-Type': MIME[ext] || 'text/plain' });
res.end(data);
});
});
server.listen(PORT, '0.0.0.0', () => console.log(`Server: http://0.0.0.0:${PORT}/`));