Re: Dynamic HTML from Python Script
- From: Dave Parker <daveparker@xxxxxxxxxxxxxxxxxx>
- Date: Wed, 11 Jun 2008 07:36:59 -0700 (PDT)
On Jun 11, 7:59 am, Lie <Lie.1...@xxxxxxxxx> wrote:
You can't make the browser refresh automatically in the server side,
Yes you can. I don't know how to do it in Python, but here's an
example in Flaming Thunder of a small, fast, light compiled server
side CGI that delivers dynamic content every 10 seconds.
# Write out the HTTP headers, followed by a blank line.
# Make sure to write CRLF and not just LF, as per HTTP
# specs. Also, turn off caching using the no-cache and
# expires options, so that caching doesn't conflict with
# refreshes.
Set CRLF to CarriageReturn+LineFeed.
Write "Refresh: 10; url=http://www.flamingthunder.com/cgi/
refresh.cgi",CRLF.
Write "Content-type: text/html",CRLF.
Write "Pragma: no-cache",CRLF.
Write "Expires: 0",CRLF.
Write "Cache-Control: no-cache",CRLF.
Write CRLF.
# Write out the dynamic information. In this
# case, we'll just write out Greenwich mean time.
Write GetGreenwichMeanTime.
For this example, the dynamic content is just Greenwich mean time.
You can see it in action at:
http://www.flamingthunder.com/cgi/refresh.cgi
To create the CGI script, I used Flaming Thunder's cross compiling
ability to compile the script under Windows, targeting Linux:
ft file refresh.ft output refresh.cgi target linux32
I then ftp'd refresh.cgi up to the cgi directory on my server, set the
permissions to 700 to make it executable, and it works (without
needing to install any bulky, plodding interpreter).
On Jun 11, 7:59 am, Lie <Lie.1...@xxxxxxxxx> wrote:
On Jun 11, 9:16 am, asdf <a...@xxxxxxxx> wrote:
On Wed, 11 Jun 2008 11:20:48 +1000, Aidan wrote:
asdf wrote:
Well, there's a few ways you could approach it.
You could create a cgi program from your script - this is probably the
solution you're looking for.
Output from the script does come up very often. There is a new output
every 10 secs and it's possible that the script might be run
indefinitely. Basically I want all that output displayed in a web
browser
Well, in that case you could simply append the new output to a static
file every 10 seconds, or whenever there is new output. That way, you
just need to refresh the static file in your browser to see updates...
Given what I understand of your situation, that's how I'd do it.
The problem with this is that browser would have to be refreshed manually
every 10 seconds. Unless there is a way to set this in the script itself..
Surely you don't think you can do that without Javascript don't you?
You can't make the browser refresh automatically in the server side,
it has to be done in the client side scripting or like Opera browser
that have an option to make it refresh a page every few seconds.
A constantly running CGI app is probably not the best idea, given
timeouts and other such constraints you might run into.
You could have the script run periodically and create a static html
file in the webroot... this would be acceptable, maybe preferable, if
the output from your script doesn't change frequently.- Hide quoted text -
- Show quoted text -- Hide quoted text -
- Show quoted text -
.
- References:
- Dynamic HTML from Python Script
- From: asdf
- Re: Dynamic HTML from Python Script
- From: Aidan
- Re: Dynamic HTML from Python Script
- From: asdf
- Re: Dynamic HTML from Python Script
- From: Aidan
- Re: Dynamic HTML from Python Script
- From: asdf
- Re: Dynamic HTML from Python Script
- From: Lie
- Dynamic HTML from Python Script
- Prev by Date: Object Manipulation and Frames
- Next by Date: Re: problems with opening files due to file's path
- Previous by thread: Re: Dynamic HTML from Python Script
- Next by thread: Re: Dynamic HTML from Python Script
- Index(es):
Relevant Pages
|