2015-09-02 35 views

回答

1

就像你在node.js中做的一樣。當有請求時,您可以閱讀url property of that request(並自行解析),並且只回答您想要的請求:

var webserver = require('webserver'); 
var server = webserver.create(); 
var service = server.listen(8080, function(request, response) { 
    if (request.url.indexOf("/test") !== -1) { 
     response.statusCode = 200; 
     response.write('<html><body>Success!</body></html>'); 
     response.close(); 
    } else { 
     response.statusCode = 404; 
     response.write('<html><body>Nothing to see here</body></html>'); 
     response.close(); 
    } 
});