provide a link to download file provide a link to download file flask flask

provide a link to download file


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.