I would like to ask you, how to do force download of file from browser in Python. I have lot of pdf files, that I force downloading with PHP, to prevent opening them in browser
<?php
if (isset($_GET['download'])) {
$link = $_GET['download'];
header('Content-disposition: attachment; filename='.$link.'');
header('Content-type: application/pdf');
readfile($link);
}
?>
I have tried like half of the internet, I used urllib, urllib2, headers,.. I believe its a simple thing that I missed, because I just learn python and I want to rewrite my site into Python to learn it. I am able to create copy of pdf files, rename them, whatever. But it always remains on the server. It doesnt start download.
Any ideas please?
Thank you, have a great day..