node.js - Can't get local file test.txt using http://localhost:8080/test.txt -


i've got server running on localhost:8080, , files arranged this:

/test     server.js     chatroom.html     test.txt 

server.js:

var express = require("express"); var app = express();  app.get("/", function(request, response) {     response.sendfile(__dirname + "/chatroom.html"); }); app.listen(8080); 

so in browser when go http://localhost:8080 served chatroom.html fine.

the problem i'm having:

but when go http://localhost:8080/chatroom.html shows me "cannot /chatroom.html"

and, likewise, if go http://localhost:8080/test.txt shows me "cannot /chatroom.html"

i don't understand what's going wrong here, appreciated!

you've defined 1 path express, root path "/". if want other files available need call app.get() them well.

or, can put static assets in directory , use express.static serve them.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -