forked from InGeniusJustin/CuHackingAmazonConnect
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.js
More file actions
44 lines (35 loc) · 1.09 KB
/
app.js
File metadata and controls
44 lines (35 loc) · 1.09 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
const express = require('express');
const app = express();
const https = require('https');
const fs = require("fs");
const path = require('path');
const router = express.Router();
const server = https.createServer({
key: fs.readFileSync('server.key'),
cert: fs.readFileSync('server.cert')
}, app).listen(process.env.port || 443);
const io = require('socket.io')(server);
server.listen(443);
const orderData = {
"food": ["Pizza", "Salad", "Starter"],
"size": ["Small", "Standard", "Large"]
}
function attrQuery(attr) {
let tempStr = "<h1>"
tempStr += orderData.size[attr[1]-1] + ' '
tempStr += orderData.food[attr[0]-1]
return tempStr + "</h1>"
}
router.get("/", (req, res) =>
{
console.log('req query:', req.query)
if (req.query.attr) {
io.emit('userAttr', JSON.stringify({"data": attrQuery(req.query.attr)}))
}
res.sendFile(path.join(__dirname + '/html/example.html'));
})
app.use('/', express.static(path.join(__dirname, 'html')))
app.use("/lib", express.static(__dirname + '/lib'));
app.use('/', router);
console.log("running on Port 443");
console.log("https://ottawa.recipes");