Robyn has some powerful features for serving static files. However, there are a couple of issues/
At the moment the docs for serving files are "hidden" in "File Uploads" https://robyn.tech/documentation/api_reference/file-uploads
Can we make this more visible by moving it to the top level of API reference (and preferably renaming it to something like "Serving Static Files")
I tried editing the docs but npm hates me ;-)
[Update] this PR starts realm code and I think it is simpler/better #1024
As we can serve directories (for CSS, etc.), providing a default would save people a lot of reading.
I'd like us to add ROBYN_STATIC_FILE_DIRECTORY
to the robyn.env file. If this is set then we automatically call app.serve_directory() to provide this static directory under the URL "/static/"
It would also seem sensible be able to add static directories to each SubRouter eg by passing a Bool argument to the function
frontend = SubRouter(name, prefix="/frontend", True) ## make /frontend/static/ serve files
frontend = SubRouter(name, prefix="/frontend", False) ## No support for /frontend/static/
frontend = SubRouter(name, prefix="/frontend") ## Default to False ie No support for /frontend/static/
The flask version of url_for supports static files but only for a single directory.
I'm thinking we could have url_for('static', 'filename.css')
to serve from the application-wide static directory
Then for the subrouters we have url_for('static', 'filename.css', subroute='RouterName')
This way we have minimal impact on our templates if we restructure the project.
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too