digitalmars.D.learn - Vibe D: Get access to files
- Alexander Zhirov (25/25) Feb 09 2024 Is there a universal way to access files (styles, scripts) for
- Alexander Zhirov (3/3) Feb 09 2024 In the files, dt specified the path to the files from the root
Is there a universal way to access files (styles, scripts) for
nested paths?
```
string datapath = "./";
auto router = new URLRouter;
router.get("/", &getReq);
router.get("*", serveStaticFiles(buildPath(datapath, "public")));
router.get("*", serveStaticFiles(buildPath(datapath, "images")));
router.get("*", serveStaticFiles(buildPath(datapath, "js")));
auto profile = new URLRouter("/profile");
profile.get("/", &getReqProfile);
profile.get("/test", &getReqProfile);
profile.get("*", serveStaticFiles(buildPath(datapath, "public")));
profile.get("*", serveStaticFiles(buildPath(datapath, "images")));
profile.get("*", serveStaticFiles(buildPath(datapath, "js")));
router.any("*", profile);
// / -> OK
// /profile -> 404
// /profile/ -> OK without css, js
// /profile/test -> OK without css, js
```

Page 404 also does not load styles if the path is similar to
`/abc/asd/asd`, but if the path is single-level, then the styles
are loaded.
Feb 09 2024
In the files, dt specified the path to the files from the root `/style.css` and now, with any path from the root, files are loaded into the page, instead of `style.css`. My mistake.
Feb 09 2024








Alexander Zhirov <azhirov1991 gmail.com>