-
-
Notifications
You must be signed in to change notification settings - Fork 27
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
Working with Blueprints #20
Comments
Hi, You can have as many blueprints and template directories as you'd like but yeah this extension is only going to look in a single static directory to digest files. Mainly because in most applications you'd output your bundles to 1 specific directory (your static directory) and Flask will serve them from there. How you bundle those files are up to you. |
I was able to compile, but tried different settings to blueprint, some cases the static_url_for method didn't match the filename to the file on the cache_manifest, other cases I just got a 404 loading the asset. I just wonder how I should config my blueprint. Basically I was not able to set my blueprint this way: my_blueprint = Blueprint(
"my_blueprint",
__name__,
static_folder="/static/my_blueprint",
static_url_path="/static/my_blueprint",
template_folder="../templates/my_blueprint"
) and use static_url_for like that: <link rel="stylesheet" href="{{static_url_for('my_blueprint.static', filename='css/style.css')}}"> the static_url_for does not match filename to cache_manifest and fallback to the file without md5 hash. If I change the above code to this: <link rel="stylesheet" href="{{static_url_for('static', filename='my_blueprint/css/style.css')}}"> It works just fine. But I don't think its the best options. Do you know if I am doing some mistake? |
The |
with url_for I get the normal file, without md5 hash. If I understood correctly this extensions uses the filename to make the match with cache_manifest.json and find the md5 version. My cache_manifest.json look like this: {"my_blueprint/css/style.css": "my_blueprint/css/style-1688c8210b6509d702b1adb96bc4d0f3.css"} This explains why this work: <link rel="stylesheet" href="{{static_url_for('static', filename='my_blueprint/css/style.css')}}"> But this doesn't: <link rel="stylesheet" href="{{static_url_for('my_blueprint.static', filename='css/style.css')}}"> I'm pretty sure that the problem is the way I think |
Yeah this extension will add the md5 hash but I was curious if Flask's docs mention using |
I had no 404 with Well, thanks for the help, I will close the issue |
No problem. Sounds like I should add a FAQ item in the docs on how to reference static files within a Blueprint. |
hi there, any updates on this one ? @ericsouza how did you compile files from blueptrints ? |
I endup splitting the frontend from the backend, so my flask application didn't have to deal with static files |
Hey, thanks for this extensions. I wonder how I would work with many blueprints. I tried some things but was no able to make it work
Basically I have an app like that:
└── flaskr
├── app.py
├── my_blueprint
│ ├── blueprint.py (this is where my blueprint its configured and with the routes passing the view_func)
│ └── views.py (with the handler functions that call render_template)
├── static
│ └── my_blueprint
│ ├── css
│ │ └── stylesheet.css
│ ├── images
│ │ └── image.png
│ └── js
│ └── main.js
└── templates
└── my_blueprint
└── index.html
With this organization I can have many blueprint and each blueprint with its own templates and static folder (similar to what Django does). Do you have any example like that? thanks a lot!!
The text was updated successfully, but these errors were encountered: