-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
38 lines (28 loc) · 976 Bytes
/
index.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
36
37
38
const path = require('path');
const express = require('express');
const cors = require('cors');
const apiRoutes = require('./api/router');
const app = express();
const port = process.env.PORT || 5000;
app.get('/', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));
});
app.get('/create-post', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'index.html'));
});
app.get('/get-ppt', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'Team ECMAniacs PPT.pdf'));
});
app.get('/get-demo', (req, res) => {
res.sendFile(path.join(__dirname, 'public', 'demo.html'));
});
// Middleware
// app.use(cors());
app.use(express.static('public'));
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use('/api', apiRoutes);
app.get('*', (req, res) => {
res.status(404).sendFile(path.join(__dirname, 'public', 'img', '404.jpg'));
});
app.listen(port, () => console.log(`[SERVER] Started`));