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

fix 'static_url_path' defaulting for empty paths #3124

merged 2 commits into from May 25, 2019


Copy link

commented Mar 18, 2019

the documentation of the application object specifies static parameters:

static_url_path – can be used to specify a different path for the static
files on the web. Defaults to the name of the static_folder folder.

static_folder – the folder with static files that should be served at
static_url_path. Defaults to the 'static' folder in the root path of the

so by my understanding,

app=Flask(__name__, static_folder='')

should allow for arbitrary (absolute) path structure for all static
files. it doesn't. but the following does:

app=Flask(__name__, static_folder='', static_url_path='')

given the above doc strings, that appears inconsistent

for this specific case (static_folder=''), stepping through the
codebase yielded:

<Rule '//' (GET, OPTIONS, HEAD) -> static>

which is an expression that can never be satisfied by a valid url

please consider this trivial patch. i hope the tests are appropriate
too, it was difficult to know how much of the mechanism to incorporate
for such a small change

commit message:

-prefix a path delimiter iff there's a path to delimit
-ensures a valid default static route rule is created on application
intialisation for the case 'static_folder=""' and implicit


  • add a changelog entry if this patch changes code

@davidism davidism modified the milestone: 1.1 May 17, 2019

fix 'static_url_path' defaulting for empty paths
-prefix a path delimiter iff there's a path to delimit
-ensures a valid default static route rule is created on application
intialisation for the case 'static_folder=""' and implicit

This comment has been minimized.

Copy link

commented May 25, 2019

It looks like this was addressed in a different way by #3182, but this solution seems more correct.

flask/ Outdated Show resolved Hide resolved

@davidism davidism added this to the 1.1.0 milestone May 25, 2019

@davidism davidism force-pushed the elbeardmorez:fix_static_url_path branch from 9f5c8cb to ed9ab2d May 25, 2019

@davidism davidism merged commit 754b729 into pallets:master May 25, 2019

12 checks passed

Flask Build #20190525.1 succeeded
Flask (Flask DocsHtml) Flask DocsHtml succeeded
Flask (Flask Pypy3Linux) Flask Pypy3Linux succeeded
Flask (Flask Python27Linux) Flask Python27Linux succeeded
Flask (Flask Python27Windows) Flask Python27Windows succeeded
Flask (Flask Python35Linux) Flask Python35Linux succeeded
Flask (Flask Python36Linux) Flask Python36Linux succeeded
Flask (Flask Python37Linux) Flask Python37Linux succeeded
Flask (Flask Python37Mac) Flask Python37Mac succeeded
Flask (Flask Python37Windows) Flask Python37Windows succeeded
Flask (Flask VersionRange) Flask VersionRange succeeded
Flask (FlaskOnNightly) FlaskOnNightly succeeded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.