-
Notifications
You must be signed in to change notification settings - Fork 182
Expand file tree
/
Copy pathapp.js
More file actions
31 lines (25 loc) · 753 Bytes
/
app.js
File metadata and controls
31 lines (25 loc) · 753 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
const express = require('express');
const http = require('http');
const cors = require('cors');
const RateLimit = require('express-rate-limit');
const port = 3000;
const app = express();
var limiter = RateLimit({
windowMs: 15 * 60 * 1000,
max: 100,
});
app.use(limiter);
app.use(cors({ origin: 'http://localhost:3000' }));
app.use('/', express.static(__dirname));
app.get('/', function (req, res) {
res.sendFile(__dirname + '/index.html');
});
app.get('/ws-streaming', function (req, res) {
res.sendFile(__dirname + '/index-ws.html');
});
const server = http.createServer(app);
server.listen(port, () =>
console.log(
`Server started on port localhost:${port}\nhttp://localhost:${port}\nhttp://localhost:${port}/ws-streaming`
)
);