473,403 Members | 2,366 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Downloading Python files

Only marginally belonging in this newsgroup... but oh well.

I've just started writing in python, and I want to make the files
available on the web. So I did the standard <a
href="mypath/myfile.py"> and not surprisingly, it displays like a
webpage, but just the code. If I gzip it, and then link to the new
file, it will download, but its so small I don't want it zipped.
How can I make this into a downloadable
file SIMPLY? The other thread seems a bit complicated...

Thanks

--
Luke St.Clair | "Ask and it will be given to you; seek and you
cl*****@uiuc.edu | will find; knock and the door will be opened
---------------------| to you." - Matthew 7:7
---
Posted via news://freenews.netfront.net
Complaints to ne**@netfront.net
Jul 18 '05 #1
4 2140
On Fri, 25 Jul 2003 15:26:49 +0000 (UTC), Luke StClair <lu**@stclair.homelinux.net> wrote:
Only marginally belonging in this newsgroup... but oh well.

I've just started writing in python, and I want to make the files
available on the web. So I did the standard <a
href="mypath/myfile.py"> and not surprisingly, it displays like a
webpage, but just the code. If I gzip it, and then link to the new
file, it will download, but its so small I don't want it zipped.
How can I make this into a downloadable
file SIMPLY? The other thread seems a bit complicated...

Thanks

If the user has .py set up for automatic shell execution of .py files, the browser
should warn of security risk and provide an option to save to disk. If the user doesn't,
then it may show as text as you describe. If that's already happened, s/he should be
able to do file>save as ... and save as a .py file somewhere. If the user is still
looking at your page with the highlighted link, s/he should be able to right-click the link
and get an option to "save link as ..." You could just tell the user about that
in association with your link(s), e.g., with the following (untested!) HTML:

Right-click <a href="mypath/myfile.py">this</a> to save myfile.py to disk.<br>
Left-click <a href="mypath/myfile.py">this</a> to open myfile.py according to your browser settings.

Note that it's really the same link, just different instructions.
I guess for different browsers YMMV.

Regards,
Bengt Richter
Jul 18 '05 #2

"Luke StClair" <lu**@stclair.homelinux.net> wrote in message
news:slrnbi2j1n.ra.lu**@stclair.homelinux.net...
Only marginally belonging in this newsgroup... but oh well.

I've just started writing in python, and I want to make the files
available on the web. So I did the standard <a
href="mypath/myfile.py"> and not surprisingly, it displays like a
webpage, but just the code.


What browser on what system? As I remember, with IE6/Win98 with
python installed, even left clicking brings up 'Downloading... open or
save' box. And there is always right click 'Download as..' option.

TJR
Jul 18 '05 #3
Luke StClair wrote:
Only marginally belonging in this newsgroup... but oh well.

I've just started writing in python, and I want to make the files
available on the web. So I did the standard <a
href="mypath/myfile.py"> and not surprisingly, it displays like a
webpage, but just the code. If I gzip it, and then link to the new
file, it will download, but its so small I don't want it zipped.
How can I make this into a downloadable
file SIMPLY? The other thread seems a bit complicated...

Thanks

In order to assure that the file is downloaded and not displayed, you
need a certain amount of control either at the client agent or the server:

1. Server: you need to be able to send the client a header which is
intended for download rather than display (content-type not set to
text/html)
2. Client: you need to be able to tell the client agent to download the
data and save it as file on the disk ("Save targer as...") rather than
display it.

Adam

Jul 18 '05 #4
Terry Reedy <tj*****@udel.edu> wrote:

"Luke StClair" <lu**@stclair.homelinux.net> wrote in message
news:slrnbi2j1n.ra.lu**@stclair.homelinux.net...
Only marginally belonging in this newsgroup... but oh well.

I've just started writing in python, and I want to make the files
available on the web. So I did the standard <a
href="mypath/myfile.py"> and not surprisingly, it displays like a
webpage, but just the code.


What browser on what system? As I remember, with IE6/Win98 with
python installed, even left clicking brings up 'Downloading... open or
save' box. And there is always right click 'Download as..' option.


That's because Microsoft is a standard unto themsleves. IE will ignore
the Content-Type header being sent by the server; instead, it will look
at the user's file type settings for the extension of the file. In this
case, the system you were testing on had no entry for the .py extension,
so downloading was the default option. But get this: if you had *wanted*
to show the code (instead of downloading), the way to do it in a
cross-platform way, compatible with every browser *except IE* would be
to set "Content-Type: text/plain" on the file. But <DWS>Microsoft knows
best, dear</DWS>, so IE would override that and make the user download
the file instead of displaying it.

BTW, for those not familiar with DWS, it means Dripping With Sarcasm.

Sorry for the vitriol against IE and Microsoft, but this has been a
*very* annoying issue for me from time to time.

--
Robin Munn <rm***@pobox.com> | http://www.rmunn.com/ | PGP key 0x6AFB6838
-----------------------------+-----------------------+----------------------
"Remember, when it comes to commercial TV, the program is not the product.
YOU are the product, and the advertiser is the customer." - Mark W. Schumann
Jul 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Michele Simionato | last post by:
I have a connection which is not 100% rock solid, so if I try to download a large file (i.e. a Linux ISO image) chances are that the connection will break. Is there a way to check periodically if...
2
by: Bala | last post by:
Hi I am trying to download the PDF files from my webserver using ASP.Net. All my files are stored at F Drive on webserver. Like this F:\Main Folder\Sub Folder\Files\File1.pdf I am...
1
by: just.starting | last post by:
Hi, My dot net client downloads files and checks for any new files time to time. The server is apache2.0.53 server. So what happens is that my file download thing works fine if I dont try to call...
0
by: just.starting | last post by:
I am having problem while downloading files from an apache server2.0.53 with php4.3.10.While downloading some files it generally stops after downloading some specific amount and then stops...
10
by: mwt | last post by:
This code works fine to download files from the web and write them to the local drive: import urllib f = urllib.urlopen("http://www.python.org/blah/blah.zip") g = f.read() file =...
4
by: aldonnelley | last post by:
Hi there: a bit of a left-field question, I think. I'm writing a program that analyses image files downloaded with a basic crawler, and it's slow, mainly because I only want to analyse files...
0
by: Bryan | last post by:
i'm trying to just download the turbogears eggs without installing it. i've read the turbogear install instructions and the easy_install help. from the easy_install web site: If you have...
7
by: Ehsan | last post by:
I foundd this code in ASPN Python Cookbook for downloading files in python but when it finished downloading files the files became corrupted and didn't open, the files in internet havn't any...
2
by: brianrpsgt1 | last post by:
I have attempted downloading and installing several different version of the win32api from Source Forge, however, each time I try to install I get the following error message: "Only part of a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.