var http = require('http');
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World\n");
});
server.listen(8000);
console.log("Server running at http://127.0.0.1:8000/");
I executed following curl commands:
curl "http://127.0.0.1:8000/"
Hello World
// space is not encoded
curl "http://127.0.0.1:8000/x y"
curl: (52) Empty reply from server
curl "http://127.0.0.1:8000/x"
Hello World
// space is encoded
curl "http://127.0.0.1:8000/x%20y"
Hello World
Can you please explain the why I get curl 52???
In this case, I want to send 500 back. Can I do that?
Even with the missing res.send
it looks like an issue with your route. you probably meant.
app.get('/item/:id', function(...) {
..
})
Note the :
before id
. This creates a variable that can be accessed on req.params.id.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With