Files
x2Skyz 012d590f40
All checks were successful
Build Docker Image / Build Docker Image (push) Successful in 6m34s
Build Docker Image / Restart Docker Compose (push) Successful in 1s
-comunicate-demo
2025-11-27 21:58:19 +07:00

26 lines
1.3 KiB
JavaScript

// 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://<YOUR_IP_ADDRESS>:${PORT}`);
console.log('---------------------------------------------------');
console.log('To find your IP: Run "ipconfig" (Windows) or "ifconfig" (Mac/Linux)');
});