javascript - How to access any file (html) one level up to localhost path in node.js? -


enter image description here

how can access above file in image localhost:2000/dummy.html

and dummy.html 1 level localhost?

one way:

__dirname + '../' + filename; 

__dirname gives path script executing from. appending ../ + filename tell node 1 level in directory path.

you should @ process module in node. lot of environment data exposed through it. e.g. process.env.pwd returns current filesystem path.


Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -