alvin77 (16) [Avatar] Offline
[ 620 bytes ]

to test error handling middleware I wrote a code as in app.ja attached.
Some remarks:

- If I have a 'test.jpg' file in main folder of my application, I can view it whatever I type, e.g. http://localhost:3000/test.jpg, http://localhost:3000, http://localhost:3000/try.jpg. I thought I should view it only by typing http://localhost:3000/test.jpg.
- I do not know why if I have not 'test.jpg' file, I cannot get in Terminal the following message: 'Error sending file!'; but rather the output in the other enclosed file.

Please, could you help me?

Evan Hahn (70) [Avatar] Offline
You've got a line that looks like this:

app.use(function(req, res) {

It should look like this:

app.use(function(req, res, next) {

That's causing the error from your screenshot.

This app is written to take ANY URL you type—http://localhost:3000, http://localhost:3000/test.jpg, http://localhost:3000/whatever/foo/boo.png—and send the image. You're getting the expected behavior there.
alvin77 (16) [Avatar] Offline
It works!