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 But on the file system, it is actually both 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? http: // which / images / / Code>
/ 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.
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
Post a Comment