-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
27 lines (21 loc) · 722 Bytes
/
app.js
File metadata and controls
27 lines (21 loc) · 722 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
const express = require('express');
const path = require('path');
const app = express();
const routes = require('./routes/index');
app.use(express.json()); // to support JSON-encoded bodies
app.use(express.urlencoded({ extended: false })); // to support URL-encoded bodies
// Set Static
app.use('/static/', express.static('static'));
// Serve frontend pages
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'static', 'index.html'));
});
app.get('/dashboard', (req, res) => {
res.sendFile(path.join(__dirname, 'static', 'dashboard.html'));
});
// Set Api and short url routes
app.use('/', routes);
// Start the server
app.listen(3000, () => {
console.log('Server started on port 3000');
});