-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
35 lines (25 loc) · 853 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import express from "express";
import path from "path";
import dotenv from "dotenv";
import { fileURLToPath } from "url";
dotenv.config();
const app = express();
const port = process.env.PORT || 3030;
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Serves static files from node_modules
//const staticModules = express.static(path.join(__dirname, "node_modules"));
// Serves Static Files from public
app.use(express.static(path.join(__dirname, "public")));
// Middleware
//app.use("/node_modules", staticModules);
app.use(express.json());
app.get("/", (req, res) => {
res.sendFile(path.join(__dirname, "public", "html", "index.html"));
});
app.use((req, res) => {
res.status(404).send("<h1>Not Found</h1>");
});
app.listen(port, () => {
console.log(`Listening on port: ${port}`);
});