v0.0.1
This commit is contained in:
21
web/server.js
Normal file
21
web/server.js
Normal file
@@ -0,0 +1,21 @@
|
||||
const express = require("express");
|
||||
const path = require("path");
|
||||
|
||||
const app = express();
|
||||
const PORT = 4002;
|
||||
const DIR = process.env.CARDS_PATH || path.join(__dirname, '../cards');
|
||||
|
||||
// Раздача статических файлов из папки, указанной в DIR
|
||||
app.use('/cards', express.static(DIR));
|
||||
|
||||
// Раздача других статических файлов из текущей папки
|
||||
app.use(express.static(__dirname));
|
||||
|
||||
// Обработка 404 ошибки
|
||||
app.use((req, res) => {
|
||||
res.status(404).sendFile(path.join(__dirname, "index.html"));
|
||||
});
|
||||
|
||||
app.listen(PORT, () => {
|
||||
console.log(`Serving app on port ${PORT} ...`);
|
||||
});
|
||||
Reference in New Issue
Block a user