D
Dale
I am using a simple python webserver (see code below) to serve up
python scripts located in my cgi-bin directory.
import BaseHTTPServer
import CGIHTTPServer
class Handler(CGIHTTPServer.CGIHTTPRequestHandler):
cgi_directories = ['/cgi-bin']
httpd = BaseHTTPServer.HTTPServer(('',8000), Handler)
httpd.serve_forever()
This works fine, but now I would like to combine the python scripts
into the server program to eliminate starting the python interpreter
on each script call. I am new to python, and was wondering if there
is a better techique that will be faster.
Also, can someone reccommend an alternative approach to
httpd.serve_forever(). I would like to perform other python functions
(read a serial port, write to an Ethernet port, write to a file, etc.)
inside the web server program above. Is there an example of how to
modify the code for an event loop style of operation where the program
mostly performs my python I/O functions until an HTTP request comes
in, and then it breaks out of the I/O operations to handle the HTTP
request.
thanks
Dale
python scripts located in my cgi-bin directory.
import BaseHTTPServer
import CGIHTTPServer
class Handler(CGIHTTPServer.CGIHTTPRequestHandler):
cgi_directories = ['/cgi-bin']
httpd = BaseHTTPServer.HTTPServer(('',8000), Handler)
httpd.serve_forever()
This works fine, but now I would like to combine the python scripts
into the server program to eliminate starting the python interpreter
on each script call. I am new to python, and was wondering if there
is a better techique that will be faster.
Also, can someone reccommend an alternative approach to
httpd.serve_forever(). I would like to perform other python functions
(read a serial port, write to an Ethernet port, write to a file, etc.)
inside the web server program above. Is there an example of how to
modify the code for an event loop style of operation where the program
mostly performs my python I/O functions until an HTTP request comes
in, and then it breaks out of the I/O operations to handle the HTTP
request.
thanks
Dale