1

How get string pathname ?

var http=require('http');
var url = require("url");
http.createServer(function(req,res){


var pathname = url.parse(req.url).pathname;
console.log("Request for " + pathname + " received.");



res.writeHead(200,{'Content-Type':'text/plain'});
res.end('Hello\n');
}).listen(8124,'127.0.0.1');
console.log('Server me!');

There is no error output,but not displayed Request for ....

1

1 Answer 1

1

This seems to work for me:

FL261:~ jvah$ node pathname
Server me!
Request for / received.

And at the same time in the other window using curl:

FL261:~ jvah$ curl http://127.0.0.1:8124/
Hello
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.