Downloading Python files

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Luke StClair

    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
    [email protected] u | will find; knock and the door will be opened
    ---------------------| to you." - Matthew 7:7
    ---
    Posted via news://freenews.netfront.net
    Complaints to [email protected] et
  • Bengt Richter

    #2
    Re: Downloading Python files

    On Fri, 25 Jul 2003 15:26:49 +0000 (UTC), Luke StClair <[email protected] omelinux.net> wrote:
    [color=blue]
    >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[/color]
    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

    Comment

    • Terry Reedy

      #3
      Re: Downloading Python files


      "Luke StClair" <[email protected] omelinux.net> wrote in message
      news:slrnbi2j1n .ra.luke@stclai r.homelinux.net ...[color=blue]
      > 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.[/color]

      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


      Comment

      • Adam

        #4
        Re: Downloading Python files

        Luke StClair wrote:
        [color=blue]
        > 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
        >
        >
        >[/color]
        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

        Comment

        • Robin Munn

          #5
          Re: Downloading Python files

          Terry Reedy <[email protected] du> wrote:[color=blue]
          >
          > "Luke StClair" <[email protected] omelinux.net> wrote in message
          > news:slrnbi2j1n .ra.luke@stclai r.homelinux.net ...[color=green]
          >> 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.[/color]
          >
          > 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.[/color]

          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>Microsof t 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 <[email protected] m> | 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

          Comment

          Working...