node.js - Accessing local path using node server -
in below code can able listen port 9080 need access local file path (d:\xampp\htdocs\ln\try\index.html) using http request
var http = require('http'); const port=9080; function handlerequest(request, response){ response.end('it works!! path hit: ' + request.url); } var server = http.createserver(handlerequest); server.listen(port, function(){ //callback triggered when server listening. hurray! console.log("server listening on: http://localhost:%s", port); });
installing http-server using node ( npm install http-server -g ). when add globally node module can run server in path.
Comments
Post a Comment