forked from Diomenios/logopedia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main_server.js
executable file
·60 lines (45 loc) · 1.65 KB
/
main_server.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
var express = require('express');
var database = require('./API/database');
const mariadb = require('mariadb');
var rateLimit = require('express-rate-limit');
const http = require('http');
var app = express();
app.enable('trust proxy');
var limiter = new rateLimit({
windowMs: 60*1000, // 15 minutes
max: 100, // limit each IP to 100 requests per windowMs
delayMs: 0 // disable delaying - full speed until the max limit is reached
});
app.use(limiter);
app.use('/api', database);
app.get('/', function(req, res) {
res.sendFile('/public/html/acceuil.html', {root: __dirname });
})
.get('/activites', function(req, res) {
res.sendFile('/public/html/activites.html', {root: __dirname });
})
.get('/acceuil', function(req, res) {
res.sendFile('/public/html/acceuil.html', {root: __dirname });
})
.get('/activites/activite-orthographe', function(req, res) {
res.sendFile('/public/html/activite-orthographe.html', {root: __dirname });
})
.get('/activites/activite-categorie', function(req, res) {
res.sendFile('/public/html/activite-categorie.html', {root: __dirname });
})
.get('/admin', function(req, res) {
res.sendFile('/public/html/admin.html', {root: __dirname });
})
.get('/resultats', function(req, res) {
res.sendFile('/public/html/resultats.html', {root: __dirname });
})
.get('/tests', function(req, res) {
res.sendFile('/public/html/tests.html', {root: __dirname });
})
// ... Tout le code de gestion des routes (app.get) se trouve au-dessus
.use('/static', express.static('public'))
.use(function(req, res, next){
res.setHeader('Content-Type', 'text/plain');
res.status(404).send('Page introuvable !');
});
app.listen(3000);