-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
39 lines (30 loc) · 950 Bytes
/
index.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
const express = require('express');
const app = express();
const path = require('path');
const http = require('http');
const bodyParser = require('body-parser');
// modules
// const jiffify = require('./app/jiffify');
const run = require('./app/dist/run');
app.use(bodyParser.urlencoded({
extended: true
}));
var port = process.env.PORT || 8082;
var server = app.listen(port, function() {
console.log('Listening on port %d', server.address().port);
console.log('http://localhost:' + port);
});
app.use(express.static(__dirname + '/client'));
app.get('/', function(req,res) {
res.sendFile((path.join(__dirname + '/client/index.html')));
});
app.post('/postCode', function(req,res) {
console.log("Received new POST request at /postCode");
var jiffified = run.parseCode(req.body.code);
if (jiffified) {
console.log('Sending back object');
res.send(jiffified);
} else {
res.send('Could not be jiffied')
}
});