Use the built-in middleware express.static -
http://expressjs.com/starter/static-files.html

Trying to implement this feature on your own can be risky if not done
properly.

On Mon, 8 Jun 2015 at 6:38 am Grant MacDonald <minevillian.g...@gmail.com>
wrote:

> Hi folks.  I have a requirement that when the user enters the route and a
> file name (ie. http://website/filename.pdf) that my node.js server will
> determine which path (out of many) where the file exists (ie. rather than
> generating a 404.)  The location of the file will be determined by the name
> of the file passed in the URL.  I'm not sure the best way to do this (I am
> using Express 4.)  Should I do the file location check when I catch the 404?
>
> Thanks. Grant.
>
> --
> Job board: http://jobs.nodejs.org/
> New group rules:
> https://gist.github.com/othiym23/9886289#file-moderation-policy-md
> Old group rules:
> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
> ---
> You received this message because you are subscribed to the Google Groups
> "nodejs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nodejs+unsubscr...@googlegroups.com.
> To post to this group, send email to nodejs@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nodejs/08e09e49-c71d-402c-ad3e-bf52843607cb%40googlegroups.com
> <https://groups.google.com/d/msgid/nodejs/08e09e49-c71d-402c-ad3e-bf52843607cb%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nodejs+unsubscr...@googlegroups.com.
To post to this group, send email to nodejs@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/CAHjDAsQzzw9Z-DNdjXVG02EppiiBkpJcC3SnKD34qu64tXjBCQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to