Forums

How to link to a downloadable file?

my page template:

   {% for key,value in list_of_files.items() %}
    <tr>
      <td>{{ key }}</td>
      <td><a href="{{ value }}" class = "w3-button w3-ripple w3-yellow">Download</a></td>
      </tr>
    {% endfor %}

and my code is:

def files():
    path = "/home/......../static/files/"
    list_of_files = {}
    for filename in os.listdir(path):
        list_of_files[filename] = "/home/....../static/files/"+filename
    return render_template("files.html",list_of_files = list_of_files)

as a result returning url :

http://username.pythonanywhere.com/home/....../static/files/xxxx.pdf

but I get 404 error, how can I solve this problem

See our help pages on how to setup and debug static files.

I am getting the same error,

Can someone help me know, how I can get this resolved?

Look at the help pages that I posted above.