-
-
Notifications
You must be signed in to change notification settings - Fork 230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start static directory support #1024
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Hi @sansyrox |
CodSpeed Performance ReportMerging #1024 will not alter performanceComparing Summary
|
I've decided that set_static_files_directory is better as it does not imply you can/should add multiple static directories. Also if the directory does not exist then throw an assertion is going to help resolve deployment issues quicker especially as it shows the exact path it's trying to use. |
Alright, one question What is the concern with
Apart from it not coming up in the search? |
for me:
|
Yes, this is very bad, and we should fix this!
you can do
Maybe it does. But it also imposes opinions and structure on the developers. Robyn is made to be extensible. We can maybe improve the implementation of |
I tried and npm told me that it hated me and I should run away :-)
You can but it doesn't help you setup a sane way of doing this. So you have to dive much deeper.
I'm not sure that offering defaults counts as imposing :-) |
I will do it then. Let me make an issue :D
Not always but here, we will be hardcoding a |
Thanks, seen it :-)
Only hardcoded as a default argument. I'm thinking that if you go for the defaults then the route is default directories to be something like
when we start supporting nested subroutes we would change to something like
|
Description
This PR fixes #1005
Work In Progress
Summary
This PR provides a simple way to add a static directory for the Robyn app and each SubRouter. It calls serve_directory but with fewer arguments and simple defaults. The goal will be to make it a one line addition eg
change from (in the initial example at https://robyn.tech/documentation/example_app/modeling_routes )
to
For the subrouter the same ( https://robyn.tech/documentation/example_app/subrouters_and_views )
'''
frontend = SubRouter(name, prefix="/frontend")
frontend.set_static_files_directory() #using a sane default directory path and "static" as the route both customisable via arguments
@frontend.get("/")
'''
what I want to support are these routes
/static/crimes.css
and '/frontend/static/fronts.css' (where frontend is the object name not the route prefix)Then we can add support to templating allowing us simple access to static files in templates which won't change when the route prefix for frontend changes
PR Checklist
Please ensure that:
Pre-Commit Instructions: