Flask file operations

I use Flask framework. A user can upload an image on my local website. Flask stores this impage in ‘uploads/images/[set of images]’. I want to access them in HTML using standard url_for approach. However, it does not work. Can anyone help me with tuning it. I know I can just use one folder, i.e. I can upload all the images to ‘upload’ folder straight away, but I have many folders in ‘upload’ folder, thus need to go this extra mile. This is what I have and it does not work:

<img src="{{  url_for('uploads/images', filename=recipe.recipe_image)  }}" alt="beautiful picture">

But this works (assuming I have my pictures all in ‘upload’ file. Also note that ‘recipe.recipe_image’ is the actual name i.e. ‘image1.jpg’ for each individual picture.

<img src="{{  url_for('uploads', filename=recipe.recipe_image)  }}" alt="beautiful picture">

Any help would be very much appreciated!

What do the routes for these urls look like?

The images are in the directory:

It is a relative path.

@toastedpitabread Do you know how to access files in that directory? Actually, I want to ask a more generic question: How to access a file using ‘url_for’ if it is not inside ‘static’ folder and has a complex route, i.e. the file is inside multiple customized folders?

I still have not found the answer… Any help would be very much appreciated!

I think you can experiment what is possible in a python/flask shell with test_request_context() as seen here:

Sorry I lost track of this thread.