-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
30 lines (25 loc) · 805 Bytes
/
app.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
var express = require('express');
var app = express();
var _ = require('underscore');
var {calculateEmptyArea} = require('./calculateEmptyArea');
var {quickSort} = require('./sort');
var bodyParser = require('body-parser');
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.post('/sort', function(req, res){
var array = req.body;
console.log(array);
var temp = quickSort(array, 0, array.length -1);
res.send(temp);
});
app.post('/calculateemptyarea', function(req, res){
var input = req.body;
console.log(input);
var result = calculateEmptyArea(input);
var object = {"result" : result};
console.log(object);
res.send(JSON.stringify(result));
})
app.listen(process.env.PORT || 3000, function(){
console.log("server successfully listening");
})