var express = require('express');
var math = require('mathjs');
var bodyParser = require('body-parser');

var handlers = require('./lib/handlers');

var app = express();

app.set('port', (process.env.PORT || 8080));

app.use(bodyParser.urlencoded({ extended: true }));

app.listen(app.get('port'), function () {
  console.log('app starting at port '+ app.get('port'));
});

var mathParser = new math.parser();

handlers.setMathParser(mathParser);

app.get('/eval', handlers.evalGet);
app.post('/eval', handlers.evalPost);

app.get('/scope/read', handlers.scopeReadGet);


@@ -23,24 +23,58 @@
 'express');%0A
+var request = require('request');%0A
 var math = r
@@ -87,24 +87,24 @@
 ('mathjs');%0A
-
 var bodyPars
@@ -396,16 +396,233 @@
 ort'));%0A
+  %0A  var appName = process.env.APP_NAME;%0A  if(appName)%0A    setInterval(function () %7B%0A      console.log('ping every 20 minutes');%0A  %09  request.get('http://' + appName + '.herokuapp.com/ping');%0A    %7D, 20 * 60 * 1000);%0A%0A
 %7D);%0A%0Avar
@@ -811,12 +811,76 @@
 eReadGet);%0A%0A
+app.get('/ping', function(req, resp) %7B%0A  resp.send('pong');%0A%7D);%0A

add ping itself