Reputation: 15
I am writing a script which will run on my server. Its purpose is to download the document. If any person hit the particular url he/she should be able to download the document. I am using urllib.urlretrieve but it download document on the server side not on the client. How to download in python at client side?
Upvotes: 0
Views: 375
Reputation: 70218
If the script runs on your server, its purpose is to serve a document, not to download it (the latter would be the urllib
solution).
Depending on your needs you can:
Content-Type
(provides document type such as "text/plain") and Content-Disposition
(provides download filename) headers and send the document dataAs your question is not more specific, this answer can't be either.
Upvotes: 2
Reputation: 3897
If the document is on your server and your intention is that the user should be able to download this file, couldn't you just serve the url to that resource as a hyperlink in your HTML code. Sorry if I have been obtuse but this seems the most logical step given your explanation.
Upvotes: 1
Reputation: 799310
Set the appropriate Content-type
header, then send the file contents.
Upvotes: 1