Skip to content
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

Add simple CDN example for static files #884

Closed
hnykda opened this issue Mar 30, 2020 · 2 comments
Closed

Add simple CDN example for static files #884

hnykda opened this issue Mar 30, 2020 · 2 comments

Comments

@hnykda
Copy link

hnykda commented Mar 30, 2020

Hi,

I am struggling with a simple task: "serve my static files from CDN (say, public google cloud storage)". In Django, I would simply do:

STATIC_URL = "https://googleapis..."

but I can't figure out how to deal with this in starlette (I am using fastapi)

Related:

@tomchristie
Copy link
Member

I'd suggest including STATIC_URL in your template contexts, and using {STATIC_URL}/whatever.css in the template.

You'll probably also want to do some config setup so that in development you serve from http://127.0.0.1/statics and include StaticFiles in that case.

@hnykda
Copy link
Author

hnykda commented Apr 1, 2020

Thanks, that was my backup plan, I was hoping for solution with url_for. But understandable, thanks.

Do you think it would be worth it to add it into docs to static files section? Should I do a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants