Reputation: 621
This question might seem a little stupid. I'm new to web development and I'm just writing a simple web app to start with. I'm using flask. The app gets some images from some other sites and save them to a folder 'savedimages'. The problem is after I deploy it on heroku, I can't open any of the images in the 'savedimages' folder. I guess this is because of the chmod of the folder isn't set to 755 or so... So how do I chmod this folder?
Thanks!
Upvotes: 1
Views: 2195
Reputation: 160005
The issue most likely isn't that the permissions are off - it is most likely that Flask is mounted at the root of your application and you don't have any rules in your Flask app to serve the images. Try adding a rule to your app:
@app.route("/savedimages/<picture>")
def display_picture(picture):
return "The picture is: {}".format(picture)
If it displays, then simply change your return to use flask.send_file
:
file_name = werkzeug.security.safe_join("/path/to/savedimages", picture)
return send_file(file_name)
Upvotes: 3