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

It resolves problems with blueprints and url_prefix "/" #1339

Closed

Conversation

guilleJB
Copy link

@guilleJB guilleJB commented Feb 5, 2015

Issue #348

I want to separate an app with various blueprints, frontend, backend, etc.. But when I try to register my frontend blueprint with follow code, my static css, images, js don't load.

front = Blueprint('front', __name__, static_folder='static', template_folder='./templates', url_prefix='/')

After debugging I found the problem. It's when try to register route, it tries to register route like //static (https://github.com/mitsuhiko/flask/blob/master/flask/blueprints.py#L68)

And then when use url_for the werkzeug routing.py (https://github.com/mitsuhiko/werkzeug/blob/master/werkzeug/routing.py#L1655) resolve url_for //static/filename it found a problem beacause there are two rules like this:

[<Rule '/static/<filename>' (HEAD, OPTIONS, GET) -> static>, <Rule '//static/<filename>' (HEAD, OPTIONS, GET) -> front.static>]

So, a simple solution like concatenate a blueprint.name before url_prefix when is "/" resolve this conflict and now we can use url_for('front.static', filename='2.jpg') routing resolves without problem.

@untitaker
Copy link
Contributor

Hello @guilleJB, thanks for your contribution! Sorry for making you wait so long, but I don't believe this is a correct fix. It special-cases a particular setting of yours, but I'm sure there's a bug somewhere else.

@untitaker untitaker closed this Jun 6, 2015
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants