Long cgi page

Discussion in 'Python' started by Simon Faulkner, Oct 13, 2003.

  1. I am writing a simple cgi app and I would like it to print the header
    of an html page and "Running..." then print the results (which take
    over a minute to calculate)

    But...

    None of the page displays until the program finishes.

    Is there any way of flushing the first half of the page out before the
    calculation starts?

    Simon
    Simon Faulkner, Oct 13, 2003
    #1
    1. Advertising

  2. sys.stdout.flush()
    See Python ref.

    Best,
    Miklós

    Simon Faulkner <> wrote in message
    news:...
    > I am writing a simple cgi app and I would like it to print the header
    > of an html page and "Running..." then print the results (which take
    > over a minute to calculate)
    >
    > But...
    >
    > None of the page displays until the program finishes.
    >
    > Is there any way of flushing the first half of the page out before the
    > calculation starts?
    >
    > Simon
    Jegenye 2001 Bt, Oct 13, 2003
    #2
    1. Advertising

  3. Simon Faulkner

    bromden Guest

    > None of the page displays until the program finishes.

    it's because the http server "waits" till the cgi program finishes,
    flushing stdout will not work

    --
    bromden[at]gazeta.pl
    bromden, Oct 13, 2003
    #3
  4. On Mon, 13 Oct 2003 18:35:44 +0100,
    Simon Faulkner <> wrote:
    > Is there any way of flushing the first half of the page out before the
    > calculation starts?


    You're better off using a redirect. On the inital request, run the
    calculation in a subprocess or a subthread and return a brief page that says
    "Please wait...". This page should contain a <META HTTP-EQUIV="Refresh">
    element that will reload the page in some suitable time span. On reloading,
    the application should check if the computation is done and either return
    the results or another "Please wait" page.

    Quixote pseudocode:

    def calc
    HTML:
     (request):
        if not request.session.computation_in_progress():
            # Fork off subprocess
        elif request.session.computation_completed():  
            "Results:"
    	...		  
        else:
            # Computation is in process
            "<html><head>"
    	'<meta http-equiv="refresh" content="10; %s">' % request.get_url()
    	'</head><body> ... </body></html>'
    
    You'd have to write the computation_completed() and computation_in_progress()
    methods.
    
    --amk
    A.M. Kuchling, Oct 14, 2003
    #4
  5. In article <>, A.M. Kuchling wrote:
    > On Mon, 13 Oct 2003 18:35:44 +0100,
    > Simon Faulkner <> wrote:
    >> Is there any way of flushing the first half of the page out before the
    >> calculation starts?

    >
    > You're better off using a redirect. On the inital request, run the
    > calculation in a subprocess or a subthread and return a brief page that says
    > "Please wait...". This page should contain a <META HTTP-EQUIV="Refresh">
    > element that will reload the page in some suitable time span. On reloading,
    > the application should check if the computation is done and either return
    > the results or another "Please wait" page.


    I don't know how to translate this to Quixote, but another way to do this
    would be to use an HTTP refresh header, which has the additional advantage
    that it's not strictly limited to HTML.

    Just a thought,
    Dave

    --
    ..:[ dave benjamin (ramenboy) -:- www.ramenfest.com -:- www.3dex.com ]:.
    : d r i n k i n g l i f e o u t o f t h e c o n t a i n e r :
    Dave Benjamin, Oct 14, 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. George Marsaglia

    Assigning unsigned long to unsigned long long

    George Marsaglia, Jul 8, 2003, in forum: C Programming
    Replies:
    1
    Views:
    658
    Eric Sosman
    Jul 8, 2003
  2. Daniel Rudy

    unsigned long long int to long double

    Daniel Rudy, Sep 19, 2005, in forum: C Programming
    Replies:
    5
    Views:
    1,175
    Peter Shaggy Haywood
    Sep 20, 2005
  3. Mathieu Dutour

    long long and long

    Mathieu Dutour, Jul 17, 2007, in forum: C Programming
    Replies:
    4
    Views:
    459
    santosh
    Jul 24, 2007
  4. Bart C

    Use of Long and Long Long

    Bart C, Jan 9, 2008, in forum: C Programming
    Replies:
    27
    Views:
    780
    Peter Nilsson
    Jan 15, 2008
  5. veryhotsausage
    Replies:
    1
    Views:
    1,776
    veryhotsausage
    Jul 4, 2008
Loading...

Share This Page