Last active
December 19, 2015 10:49
-
-
Save Tukki/5943755 to your computer and use it in GitHub Desktop.
flask with static file, but not css/js... temporary, in development
This file contains 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
http://stackoverflow.com/questions/13706382/how-to-get-static-files-in-flask-without-url-forstatic-file-name-xxx | |
You can Setup your own route to serve static | |
files. Add this method and update the static path director in the send_from_directory method and your img tag should work. | |
@app.route('/pic/<path:filename>') | |
def send_pic(filename): | |
return send_from_directory('/path/to/static/files', filename) | |
For a production app however, you should setup your server to serve static files directly. | |
It would be much faster and use less server resources, but for a few users it shouldn't be a problem. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment