I am using python flask. I want to provide a url in template which varies in filename.
Folder structure:
project_folder/download/pdf <-images in this folder
url_for('download/pdf/filenameXYZ.pdf') didnt worked.
If you want to return static content you should tell Flask that you want static content :)
As you can see in this example: http://flask.pocoo.org/docs/patterns/jquery/?highlight=static
You need something like this:
url_for('static', filename='download/pdf/filenameXYZ.pdf')
url_for takes a flask function that has a route associated with it and any parameters you want to pass to that view. What url_for will do is return the URL path for that function.
If you want to display a PDF then you need to render a template which contains a HTML or tag. There's actually a bunch of different ways to handle this
An example that you could use in a template is
<embed src="/download/pdf/the.pdf" width="500" height="375">
the main point is that url_for doesn't take a file path.