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

static file would not send to browser correctly #331

Closed
heavenshell opened this issue Sep 30, 2011 · 4 comments · Fixed by pallets/werkzeug#1137
Closed

static file would not send to browser correctly #331

heavenshell opened this issue Sep 30, 2011 · 4 comments · Fixed by pallets/werkzeug#1137

Comments

@heavenshell
Copy link

Hi,

I've got a issue about static file.

When I put css file in /static/css/style.css in static directory and I described view function with Variable Rules.
Please see sample code on https://gist.github.com/1254213

GET /static/css/style.css request dispatch to view function and css file did not send to browser correctly.
I expected to GET /static/css/style.css should send css file to browser, not dispatch to view function.

Regards.

@thomaslee
Copy link

thomaslee commented Nov 27, 2011

This is happening because werkzeug's Rule.match_compare_key and Rule.build_compare_key give preference to "more complex" rules (i.e. rules with more arguments)

Although it could be argued this is "expected behaviour" it's also kind of counter-intuitive.

Should we afford special precedence to the static directory over user-defined routes?

@hyunchel
Copy link
Contributor

hyunchel commented Jun 3, 2016

Just to note, this is still relevant issue to the current master.
I was able to reproduce the same behavior with the given sample code.

@jeffwidman
Copy link
Contributor

Forked the gist just in case the OP accidentally removes it in the future: https://gist.github.com/jeffwidman/11d8b8d952abca30756ca4ba01909143

@davidism
Copy link
Member

davidism commented Jun 5, 2016

We could allow passing a different rule class to add_url_rule and override Rule.match_compare_key to return something like 1, float('-inf'), 200. But that seems a little extreme for just this. I'm actually surprised this hasn't come up more often, /<string>(/<string>)+ seems like it would be a common rule.

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 a pull request may close this issue.

5 participants