"Dynamic" website content

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

    #1

    "Dynamic" website content

    Basically I have written a cgi script to automatically download TIFF
    images of patents from the US patent office.

    What I want is that the user can see what is happening when the images
    are being downloaded, because it takes a while to download them and
    there can be anything up to 30 individual files for each image.

    Is there a way of using Python or any other means, that I could it
    could print on the webpage:

    Downloading image 1

    Downloading image 2
    ....
    Downloading image X

    as the individual pictures are being downloaded so the user doesn't
    think the program is hanging?

  • Diez B. Roggisch

    #2
    Re: "Dynamic&q uot; website content

    sophie_newbie schrieb:[color=blue]
    > Basically I have written a cgi script to automatically download TIFF
    > images of patents from the US patent office.
    >
    > What I want is that the user can see what is happening when the images
    > are being downloaded, because it takes a while to download them and
    > there can be anything up to 30 individual files for each image.
    >
    > Is there a way of using Python or any other means, that I could it
    > could print on the webpage:
    >
    > Downloading image 1
    >
    > Downloading image 2
    > ...
    > Downloading image X
    >
    > as the individual pictures are being downloaded so the user doesn't
    > think the program is hanging?[/color]

    Why? In my browser, if I download a file, the browser itself shows a
    nice progress-bar. I guess what you are after is a way to trigger a
    download while the current page is displayed in the browser.

    Looking at sf, one can see that the header of the site explaining to you
    that your download now starts contains this:

    <meta http-equiv="refresh" content="5;
    URL=http://peterhost.dl.so urceforge.net/sourceforge/winavr/WinAVR-20050214-install.exe"
    />


    That means that 5 seconds later, the URL is fetched. As the type is
    neither image nor HTML, the browser will download it.

    In conclusion, it should even suffice to just let the user click that
    link itself. Then the browser should start downloading that image of yours.

    Regards,

    Diez

    Comment

    • sophie_newbie

      #3
      Re: &quot;Dynamic&q uot; website content

      To give you a better explaination of what I want, you could visit
      www.pat2pdf.org.

      Type in 123456 as the patent number, you see what it does? It tells the
      user that it is requesting the various TIFF images and then displays
      the link to the PDF file that it has created.

      This is exactly what I want to do, so if anyone has any idea how it is
      done I would be greatful.

      I'm not asking how to get the TIFF files of create the PDF etc, that is
      grand, just how it updates the screen with its progress like that...

      Comment

      • Diez B. Roggisch

        #4
        Re: &quot;Dynamic&q uot; website content

        sophie_newbie schrieb:[color=blue]
        > To give you a better explaination of what I want, you could visit
        > www.pat2pdf.org.
        >
        > Type in 123456 as the patent number, you see what it does? It tells the
        > user that it is requesting the various TIFF images and then displays
        > the link to the PDF file that it has created.
        >
        > This is exactly what I want to do, so if anyone has any idea how it is
        > done I would be greatful.
        >
        > I'm not asking how to get the TIFF files of create the PDF etc, that is
        > grand, just how it updates the screen with its progress like that...[/color]

        It seems that they just fetch the tiff and then write "Fetched
        %i<br/>\n" into the page.

        The important thing then is to flush the stdout, so that the data is
        actually transmitted over the network. And I guess you have to provide a
        header that accounts for the number of bytes you want to write (the
        total bytes of the html-page that is), by specifying something equals or
        maybe greater than the overall page.

        Regards,

        Diez


        Comment

        • Christoph Haas

          #5
          Re: &quot;Dynamic&q uot; website content

          On Saturday 21 January 2006 20:42, sophie_newbie wrote:[color=blue]
          > To give you a better explaination of what I want, you could visit
          > www.pat2pdf.org.
          >
          > Type in 123456 as the patent number, you see what it does? It tells the
          > user that it is requesting the various TIFF images and then displays
          > the link to the PDF file that it has created.[/color]

          Ah, so you are trying to get the page displayed while your CGI is still
          running? Try flushing stdout after you print something. Otherwise the
          output will only be sent when the CGI ends or the buffer is full.

          Kindly
          Christoph
          --
          Never trust a system administrator who wears a tie and suit.

          Comment

          • Alex Martelli

            #6
            Re: &quot;Dynamic&q uot; website content

            Christoph Haas <email@christop h-haas.de> wrote:
            [color=blue]
            > On Saturday 21 January 2006 20:42, sophie_newbie wrote:[color=green]
            > > To give you a better explaination of what I want, you could visit
            > > www.pat2pdf.org.
            > >
            > > Type in 123456 as the patent number, you see what it does? It tells the
            > > user that it is requesting the various TIFF images and then displays
            > > the link to the PDF file that it has created.[/color]
            >
            > Ah, so you are trying to get the page displayed while your CGI is still
            > running? Try flushing stdout after you print something. Otherwise the
            > output will only be sent when the CGI ends or the buffer is full.[/color]

            ....unless you run Python with the -u option, which makes output
            unbuffered (and, if on Windows where it matters, binary). However, it's
            not sufficient to ensure the user's browser will show the messages you
            want when you want. A much more reliable way to achieve that is to use
            timed redirects, or an AJAX (Javascript-based) solution.


            Alex

            Comment

            • sophie_newbie

              #7
              Re: &quot;Dynamic&q uot; website content

              Flushing to stdout doesn't seem to work anyway.

              Honestly have no idea how you'd implement it in Javascript so might
              have an ask on one of their forums...

              Comment

              • Peter Maas

                #8
                Re: &quot;Dynamic&q uot; website content

                sophie_newbie schrieb:[color=blue]
                > Flushing to stdout doesn't seem to work anyway.
                >
                > Honestly have no idea how you'd implement it in Javascript so might
                > have an ask on one of their forums...
                >[/color]

                I think you need HTTP push to update the client page. See
                http://wp.netscape.com/assist/net_sites/pushpull.html for
                information about HTTP push.

                Peter Maas, Aachen

                Comment

                • sophie_newbie

                  #9
                  Re: &quot;Dynamic&q uot; website content

                  To be honest that doesn't seem to work. Also it seems that only Mozilla
                  based browsers support server push.

                  Maybe it is something to do with how Apache is configured?

                  Or is Python buffering the output? Is there a line of code to make
                  python unbeffered?

                  Comment

                  • sophie_newbie

                    #10
                    Re: &quot;Dynamic&q uot; website content

                    I am running apache on windows by the way. I think there may be issues
                    with unbuffered output on windows...

                    Comment

                    Working...