forked from johntango/pacMan
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
28 lines (26 loc) · 793 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
var express = require('express');
var bodyParser = require('body-parser');
var path = require('path');
var app = express();
app.use(bodyParser.json()); // support json encoded bodies
app.use(bodyParser.urlencoded({ extended: true }));
var data = [];
var root = path.resolve(__dirname) + '/public/';
app.get('/', (req, res) => {
res.sendFile('block.html', { 'root': root });
});
app.get('/set', function(req, res) {
console.log(JSON.stringify(req.query));
data.push({ x: req.query.x });
res.send({
x: req.query.x
});
});
app.get('/get', function(req, res) {
res.send(JSON.stringify(data));
});
app.get('/pac', function(req, res) {
res.sendFile('/PacMan' + req.query.id + '.png', { 'root': root });
});
app.listen(3000);
console.log("Running on port 3000");