Flask with PyInstaller does not show images added at runtime #4180
Replies: 2 comments 2 replies
-
IMO, it's more like an issue related to your own code or Pyinstaller instead of a bug in Flask (notice this issue tracker is for issues related to Flask itself), so I'm going to transfer this to our GitHub discussion. |
Beta Was this translation helpful? Give feedback.
-
Flask adds a from flask import send_from_directory
@app.route('/images/<path:filename>')
def images(filename):
base_path = path_to_the_images_folder
return send_from_directory(base_path, filename) Then you can get the image link in the template like this:
|
Beta Was this translation helpful? Give feedback.
-
I have a simple app running on Flask, which displays images from a directory. Which works fine, until I create an executable using Pyinstaller. This executable also works when there were already some images at the time of creation, but it can't load any later added images, I guess it just bundles all the existing images. I tried with both a single file and a directory, nothing worked. I would be really grateful if somebody can give me some direction on this.
For more detail and sample code to reproduce this issue is here.
Beta Was this translation helpful? Give feedback.
All reactions