Download file dialog to local PC when running from PythonAnywhere

285 views
Skip to first unread message

Jogi

unread,
Mar 14, 2012, 8:52:39 AM3/14/12
to web2py-users
Hi,
in fact I have 3 questions:
1. Is there a simple dialogue which lets you chose a download
directory (and then eventually to download the file(s))?
2. I set up web2py so that it's run from PythonAnywhere. Now, if I
read out the directories or download files the path is located on the
servers of PythonAnywhere. But how can I achieve that they are
downloaded to my local computer?
3. I'm using bioPython to analyze a biological dataset. If I run this
from PythonAnywhere+web2py and save these data locally before
analyzing them, ... can this be done? Can web2py access to the users
local drive to access the files and analyze them? or do the files have
to be located at the server from where I run web2py?

If you need/want to have further information, feel free to ask... (of
course ;-))
Thx

Anthony

unread,
Mar 14, 2012, 11:33:34 AM3/14/12
to web...@googlegroups.com
Hi,
in fact I have 3 questions:
1. Is there a simple dialogue which lets you chose a download
directory (and then eventually to download the file(s))?

If you have a link to download a file, the browser handles the dialog that allows you to choose the download folder and download the file. Some file types that the browser recognizes (e.g., PDF, images, audio, video) may be displayed/played by default rather than downloaded by the browser. In that case, you can force the browser to prompt for download by setting the 'Content-Disposition' header to 'attachment; filename="myfile"'. If you're using the web2py response.download() method, it takes an "attachment" argument, which you can simply set to True. For static files, you can append "?attachment" to the end of the URL.
 
2. I set up web2py so that it's run from PythonAnywhere. Now, if I
read out the directories or download files the path is located on the
servers of PythonAnywhere. But how can I achieve that they are
downloaded to my local computer?

That doesn't sound right. Can you show some code? If the web page in your browser includes a link to download a file from the server, your browser would prompt you to save it on your local machine. It sounds like you're doing something else.
 
3. I'm using bioPython to analyze a biological dataset. If I run this
from PythonAnywhere+web2py and save these data locally before
analyzing them, ... can this be done? Can web2py access to the users
local drive to access the files and analyze them? or do the files have
to be located at the server from where I run web2py?

If the files are on the local drive, the user would have to upload them to the server for web2py to be able to process them (unless, of course, web2py is running on the local machine, which doesn't seem to be the case here).

Anthony

Wikus van de Merwe

unread,
Mar 15, 2012, 6:48:13 AM3/15/12
to web...@googlegroups.com
It looks to me that when you say "download" you mean "upload". If a user sends a file to a server, she uploads it.
I recommend you to read about upload field in the book:
http://web2py.com/books/default/chapter/29/7#SQLFORM-and-uploads

Reply all
Reply to author
Forward
0 new messages