{"size": 872, "ext": "js", "max_stars_repo_path": "server.js", "max_stars_repo_name": "sirchristian/nodescraper", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "server.js", "max_issues_repo_name": "sirchristian/nodescraper", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "server.js", "max_forks_repo_name": "sirchristian/nodescraper", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.5675675676, "max_line_length": 58, "alphanum_fraction": 0.6433486239}
var express = require('express');
var bodyParser = require('body-parser');
var scraper = require('./lib/scraper');

var app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

app.get('/', function (request, response) {
  response.sendFile(__dirname + '/static/usage.html');
});

app.post('/scrape', function (request, response) {
  var d = require('domain').create();
  d.on('error', function(err){
    response.send('Error Parsing JSON');
  });

  d.run(function() {
    scraper.scrape(request.body.args.url, function(title){
      console.log('title: ' + title);
      response.send(title);
    })
  });
});

app.use(express.static('static'));

var server = app.listen(3000, function () {

  var host = server.address().address;
  var port = server.address().port;

  console.log('Listening at http://%s:%s', host, port);

});
