Downloading Python files

Discussion in 'Python' started by Luke StClair, Jul 25, 2003.

  1. Luke StClair

    Luke StClair Guest

    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
    | will find; knock and the door will be opened
    ---------------------| to you." - Matthew 7:7
    ---
    Posted via news://freenews.netfront.net
    Complaints to
    Luke StClair, Jul 25, 2003
    #1
    1. Advertising

  2. On Fri, 25 Jul 2003 15:26:49 +0000 (UTC), 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

    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
    Bengt Richter, Jul 25, 2003
    #2
    1. Advertising

  3. Luke StClair

    Terry Reedy Guest

    "Luke StClair" <> wrote in message
    news:...
    > 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
    Terry Reedy, Jul 25, 2003
    #3
  4. Luke StClair

    Adam Guest

    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
    Adam, Jul 25, 2003
    #4
  5. Luke StClair

    Robin Munn Guest

    Terry Reedy <> wrote:
    >
    > "Luke StClair" <> wrote in message
    > news:...
    >> 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 <> | 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
    Robin Munn, Jul 29, 2003
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marina
    Replies:
    1
    Views:
    365
    S. Justin Gengo
    Jul 16, 2003
  2. Tony K
    Replies:
    6
    Views:
    1,904
    Jacob Yang [MSFT]
    Aug 28, 2003
  3. Vic
    Replies:
    1
    Views:
    317
    Steve C. Orr [MVP, MCSD]
    Oct 29, 2003
  4. Charlie@CBFC
    Replies:
    0
    Views:
    319
    Charlie@CBFC
    Jan 7, 2004
  5. WizyDig

    Downloading files with ie on a mac

    WizyDig, Feb 4, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    345
    Rimu Atkinson
    Feb 4, 2004
Loading...

Share This Page