Authored by 周奇琪

添加谷歌地图服务的代理

var express = require('express');
var app = express();
var request = require('request');
var fs = require('fs');
var app = express();
app.use(function(req, res, next){
console.log('%s %s', req.method, req.url);
next();
... ... @@ -70,10 +71,19 @@ app.post('/fb',function(req,res)
});
});
app.listen(80);
app.get('/google',function(req,res)
{
request('http://maps.google.cn/maps/api/geocode/json'+req._parsedUrl.search, function (error, response, body)
{
if (error && response.statusCode != 200)
{
console.log(error);
}
res.send(body);
});
})
console.log('OK!');
... ...
... ... @@ -4,7 +4,7 @@
"description": "facebook和谷歌服务代理",
"main": "app.js",
"dependencies": {
"express": "^4.12.0",
"express": "3.4.8",
"fb": "0.7.0",
"request": "2.53.0"
},
... ...