-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
30 lines (24 loc) · 926 Bytes
/
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
// Require express and create an instance of it
const express = require('express');
const app = express();
const path = require('path');
const hostname = 'localhost';
const port = 5000;
// save static files like images, scripts and css in `public`...
app.use(express.static(__dirname + '/public'));
// return the qrcode view
app.get('/qr/:char?', function (req, res) {
res.status(200).sendFile(path.join(__dirname + '/public/views/qrcode.html'));
});
//return arjs view
app.get('/ar/:char?', function (req, res) {
res.status(200).sendFile(path.join(__dirname + '/public/views/arjs.html'));
});
// Change the 404 message modifing the middleware
app.use(function(req, res, next) {
res.status(404).sendFile(path.join(__dirname + '/public/views/404.html'));
});
// start the server in the port 3000 !
app.listen(port, hostname , function () {
console.log(`Server running at http://${hostname}:${port}/`);
});