Skip to content

Retrieval / comparison of Flask application static content endpoint(s) #4136

Closed Answered by tachyondecay
jayaddison asked this question in Q&A
Discussion options

You must be logged in to vote

I've played around with your _static_rules_endpoint function and made some discoveries that will hopefully help.

There's good news! Your approach seems to work fine for Blueprint static folders and additional URL rules that point to send_static_file. To me, this seems to indicate the only thing you need to account for is a built-in static endpoint registered to the static_url_path on an app object.

TL;DR My Suggested Solution

You can do this by changing line 439 to

if rule.endpoint == 'static' or unwrap_method(view) is send_static_file:

Initial Test Code

Here's my test code:

from flask import Flask, Blueprint

app = Flask(__name__)

@app.shell_context_processor
def inject():
	return {'fin…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@jayaddison
Comment options

@tachyondecay
Comment options

@davidism
Comment options

Answer selected by jayaddison
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants