Okay, let’s say I have a database
Class Content(db.Model):
code=db.TextProperty()
And I wanted to supply a download link on the webpage that would download the content of code. How would I do this?
I am using python and jinja2
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You’d create a view that sends back the content of
code(assuming that you’re using the “webapp” framework):Note that you might want to set the
Content-Typeto something more specific. Also, if you want to force the browser to download the file (instead of possibly displaying the file), you can set theContent-Dispositionheader:headers['Content-Disposition'] = 'attachment; filename=some_filename.txt'.