Created
April 4, 2012 16:28
-
-
Save ento/2303562 to your computer and use it in GitHub Desktop.
Given a (static) endpoint, return its actual filesystem location.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| from flask import current_app, request | |
| def static_file_for(endpoint, filename=None): | |
| if endpoint[0] == '.' and request.blueprint: | |
| folder = current_app.blueprints[request.blueprint].static_folder | |
| else: | |
| folder = current_app.static_folder | |
| return os.path.join(folder, filename) if folder else None |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment