-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
48 lines (35 loc) · 1.3 KB
/
Copy pathserver.js
File metadata and controls
48 lines (35 loc) · 1.3 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
require('dotenv').config();
const express = require('express');
const cors = require('cors');
const apiControllers = require('./controllers/index');
const database = require('./db/database');
const app = express();
app.use(cors({ optionsSuccessStatus: 200 })); // some legacy browsers choke on 204
app.use('/public', express.static(process.cwd() + '/public'));
app.get('/', function (req, res) {
res.sendFile(process.cwd() + '/views/index.html');
});
app.get('/shorturl', function (req, res) {
res.sendFile(process.cwd() + '/views/url-shortener/index.html');
});
app.get('/shorturl/:shorturl', function (req, res) {
res.redirect(`/api/shorturl/${req.params.shorturl}`);
});
app.get('/fileanalyse', function (req, res) {
res.sendFile(process.cwd() + '/views/file-metadata/index.html');
});
app.get('/whoami', function (req, res) {
res.sendFile(process.cwd() + '/views/header-parser/index.html');
});
app.get('/timestamp', function (req, res) {
res.sendFile(process.cwd() + '/views/timestamp/index.html');
});
app.get('/exercise', function (req, res) {
res.sendFile(process.cwd() + '/views/exercise-tracker/index.html');
});
app.use('/api', apiControllers);
const port = process.env.PORT || 3000;
app.listen(port, function () {
console.log('Your app is listening on port ' + port);
database.connect();
});