Guest User

Untitled

a guest
Jan 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. var app = require('express').createServer(),
  2. fs = require('fs'),
  3. geolib = require('./geolib').geolib,
  4. http = require('http');
  5.  
  6. app.get('/', function(req, res){
  7. res.send('Hello World');
  8. });
  9.  
  10. app.get('/distance/:lat1/:lng1/:lat2/:lng2', function(req, res){
  11. var distance = geolib.getDistance({latitude: req.params.lat1, longitude: req.params.lng1 }, {latitude: req.params.lat2, longitude: req.params.lng2});
  12. res.send('Distance from ' + req.params.lat1 + ',' + req.params.lng1 + ' to ' + req.params.lat2 + ',' + req.params.lng2 + ' is ' + distance + ' km');
  13. });
  14.  
  15.  
  16. app.get('/twitter', function(req, res){
  17. http.request(
  18. {
  19. host: 'api.twitter.com',
  20. port: 80,
  21. method: 'GET',
  22. path: '/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=manuelbieh&count=2'
  23. },
  24. function(resp) {
  25. //console.log(resp);
  26. //res.send(JSON.stringify(resp.headers));
  27. }
  28. );
  29. res.send('twitter');
  30. });
  31.  
  32. app.listen(3000);
Add Comment
Please, Sign In to add comment