// 1. สร้างไฟล์นี้ในโฟลเดอร์เดียวกับ index.html // 2. รันคำสั่ง: npm install express (ถ้ายังไม่มี) // 3. สตาร์ทเซิร์ฟเวอร์: node server_frontend.js const express = require('express'); const path = require('path'); const app = express(); const PORT = 80; // พอร์ตสำหรับหน้าเว็บ (แยกกับ API 1011) // ให้บริการไฟล์ Static ในโฟลเดอร์ปัจจุบัน app.use(express.static(path.join(__dirname))); // Route หลักส่ง index.html app.get('/', (req, res) => { res.sendFile(path.join(__dirname, 'index.html')); }); // สั่งให้ Listen ทุก IP ในเครื่อง (0.0.0.0) app.listen(PORT, '0.0.0.0', () => { console.log('---------------------------------------------------'); console.log(`🚀 Frontend Server running!`); console.log(`🏠 Local: http://localhost:${PORT}`); console.log(`📡 Network: http://:${PORT}`); console.log('---------------------------------------------------'); console.log('To find your IP: Run "ipconfig" (Windows) or "ifconfig" (Mac/Linux)'); });