-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
31 lines (23 loc) · 732 Bytes
/
Copy pathserver.js
File metadata and controls
31 lines (23 loc) · 732 Bytes
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
import express from "express";
import path from "path";
import { fileURLToPath } from 'url';
import { dirname } from 'path'
import { alias } from "./src/routes/Alias.js";
const app = express();
const PORT = 3000;
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const PATH = path.join(__dirname, 'src','views');
// Setup view engine
app.set("view engine", "ejs");
app.set("views", PATH);
// Setup static files
app.use(express.static(path.join(__dirname, 'src', 'public')));
// Setup forms
app.use(express.urlencoded({ extended: true }));
// Routes
app.use("/", alias);
app.listen(PORT, ()=>{
console.log("Listening on port: " +
PORT + " (http://localhost:" + PORT + ")");
});