node.js - Is there any way to have Express draw from two file system directories for one web directory? -


Say that I want a clear directory, via http: // which / images / / Code>

But on the file system, it is actually both / users / me / www / images and / users / me / moreimages / . So if I request the http: //whatever/images/selfie.jpg , then it first searches for / user / iMA / www / images / selfie.jpeg , And if not found, serve / user / me / more / live / JPEG instead.

I can think of some of the ugly ways of doing this, but I want to do it in "right" and hopefully straightforward way. Does the expression have some work, where I can do it to do this?

Yes, this is possible. Just mounted on the / images in two instances:

  router.use ('/ images', express.static ('/ users / me / images /') ); Router. ('/ Images', express.static (' / user / mine / more images' '));  

If the request in the first instance of the middleware is not satisfied, the second will be processed, and so on.


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -