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.

run server in computer below shown image


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -