Добавлен сервер на Express для обслуживания статических файлов и главной страницы
This commit is contained in:
1 parent
b7d803c5aa
commit
a72c50945f
1 file changed
+19
@@ -0,0 +1,19 @@
|
||||
const express = require('express');
|
||||
const path = require('path');
|
||||
|
||||
const app = express();
|
||||
const PORT = 3000;
|
||||
|
||||
// Middleware для обслуживания статических файлов из папки "src" и корня приложения
|
||||
app.use('/src', express.static(path.join(__dirname, 'src')));
|
||||
app.use('/', express.static(path.join(__dirname, '')));
|
||||
|
||||
// Главная страница
|
||||
app.get('/', (req, res) => {
|
||||
res.sendFile(path.join(__dirname, 'index.html'));
|
||||
});
|
||||
|
||||
// Запуск сервера
|
||||
app.listen(PORT, '0.0.0.0', () => {
|
||||
console.log(`Server is running on http://0.0.0.0:${PORT}`);
|
||||
});
|
||||
Reference in new issue
Block a user