0

I have a flask app which seeks to fetch images from an API and serve them to the user.

Currently, the app works by fetching an image, saving it to /static/images/image_xx.jpg, then creating the relevant view with

render_template(
            myview.html,
            image_path=f"/static/images/image_xx.jpg")

I'd like to get rid of the image data after serving it. So far I've been doing it by simply looping purging any images in /static/images before I make the request and save the image to serve. However that's causing concurrency issues, and when traffic is high some users images get deleted before being served.

Is there a better way of doing this? Thanks!

0 Answers0