Small, Local Web/CGI Server Advice 
Author Message
 Small, Local Web/CGI Server Advice

I'm attempting to create my first major python app for a company that
wants to run Web (HTML) pages and CGI scripts on their salespeople's
laptop computers.  Basically, the salesperson would run a local Web
server that allows for basic CGI scripts to be run.  The customer is
pushing hard that they want to use their Web browser as the client and
to have a local server serving CGI/HTML that also is running on that
laptop (that wouldn't have been my first choice, but those are the
constraints I'm working with...)

I've tried to use CGIHTTPServer, but I am having problems getting that
to work on Windows ME/98 (using ActiveState Python 2.1 - HTML is
served just fine, but CGIs cause EXPLORER to crash).  Any advice on a
small, preferably Python based Web server that I can run that will
support CGI?  I'd love to use something like Medusa if I could figure
out how to get it to support CGIs.  I really don't want to use a
'large' server like Apache, since I'm really just trying to run a
lightweight server.

Any advice would be GREATLY appreciated!!!

Thanks,

Jeremy.



Sun, 16 Nov 2003 20:35:45 GMT  
 Small, Local Web/CGI Server Advice

Quote:
> support CGI?  I'd love to use something like Medusa if I could figure
> out how to get it to support CGIs.  I really don't want to use a
> 'large' server like Apache, since I'm really just trying to run a
> lightweight server.

I had the same problem as you. I decided to stick with Medusa.
It has several ways to call Python code, Bobo being one of the
most elegant ones (it maps an URI to a Python function call,
parameters included).

Have you tried looking at http://yahoogroups.com/group/medusa/messages ?



Sun, 16 Nov 2003 21:00:51 GMT  
 Small, Local Web/CGI Server Advice

Quote:
> support CGI?  I'd love to use something like Medusa if I could figure
> out how to get it to support CGIs.  I really don't want to use a
> 'large' server like Apache, since I'm really just trying to run a
> lightweight server.

I had the same problem as you. I decided to stick with Medusa.
It has several ways to call Python code, Bobo being one of the
most elegant ones (it maps an URI to a Python function call,
parameters included).

Have you tried looking at http://yahoogroups.com/group/medusa/messages ?



Sun, 16 Nov 2003 21:00:51 GMT  
 Small, Local Web/CGI Server Advice
i agree w/ the other poster that Medusa is the better choice, but in a pinch
IIS will work with python cgi and or python asp pages giving you a few
options.

-d


Quote:
> I'm attempting to create my first major Python app for a company that
> wants to run Web (HTML) pages and CGI scripts on their salespeople's
> laptop computers.  Basically, the salesperson would run a local Web
> server that allows for basic CGI scripts to be run.  The customer is
> pushing hard that they want to use their Web browser as the client and
> to have a local server serving CGI/HTML that also is running on that
> laptop (that wouldn't have been my first choice, but those are the
> constraints I'm working with...)

> I've tried to use CGIHTTPServer, but I am having problems getting that
> to work on Windows ME/98 (using ActiveState Python 2.1 - HTML is
> served just fine, but CGIs cause EXPLORER to crash).  Any advice on a
> small, preferably Python based Web server that I can run that will
> support CGI?  I'd love to use something like Medusa if I could figure
> out how to get it to support CGIs.  I really don't want to use a
> 'large' server like Apache, since I'm really just trying to run a
> lightweight server.

> Any advice would be GREATLY appreciated!!!

> Thanks,

> Jeremy.



Sun, 16 Nov 2003 22:23:10 GMT  
 Small, Local Web/CGI Server Advice

Quote:
> [snip]
>laptop computers.  Basically, the salesperson would run a local Web
>server that allows for basic CGI scripts to be run.  The customer is
> [snip]

Hi Sloth,

I can recommend Xitami (http://www.xitami.com) as a webserver,
which is free of charge and available for different platforms.
You can start Python scripts thru CGI (Python interpreter is
started for each script, though).

HTH
Rdiger



Sun, 16 Nov 2003 22:28:08 GMT  
 Small, Local Web/CGI Server Advice

Quote:
> I'm attempting to create my first major Python app for a company that
> wants to run Web (HTML) pages and CGI scripts on their salespeople's
> laptop computers.  Basically, the salesperson would run a local Web
> server that allows for basic CGI scripts to be run.  The customer is
> pushing hard that they want to use their Web browser as the client and
> to have a local server serving CGI/HTML that also is running on that
> laptop (that wouldn't have been my first choice, but those are the
> constraints I'm working with...)

I think these guys have a VERY good idea, actually.  This way
their salespeople can switch from local (perhaps not-latest)
data to accessing live data whenever they can plug their laptops
to the net.

Quote:
> I've tried to use CGIHTTPServer, but I am having problems getting that
> to work on Windows ME/98 (using ActiveState Python 2.1 - HTML is
> served just fine, but CGIs cause EXPLORER to crash).  Any advice on a
> small, preferably Python based Web server that I can run that will
> support CGI?

It's not Python based, but Xitami, http://www.imatix.com/html/xitami/,
is what I ended up for a similar need (I don't recall CGIHTTPServer
giving trouble, either -- once I had ensured w9xpopen.exe was in all
the right places, python run with -u, etc, of course; but Xitami was
better).  Runs on everything from Windows 3.1 up, installs like a
snap, is VERY lightweight, almost no admin (and that little, web-
based), virtual hosts, SSI... as well as CGI, it supports LRWP, 'long
running web processes', designed by Robin Dunn (see, we *HAVE* a
Python connection!-), similar to FastCGI but simpler, includes a
lrwplib Python extension allowing very easy use, example given:

from lrwplib import LRWP

def main():
    lrwp = LRWP('hello', 'localhost', 81)
    lrwp.connect()
    count = 0
    while count < 5:        # exit after servicing 5 requests
        count = count + 1
        req = lrwp.acceptRequest()
        req.out.write('Content-type: text/html\r\n\r\n')
        req.out.write('<HTML><HEAD><TITLE>hello</TITLE><')
        req.out.write('</HEAD>\n')
        req.out.write('<H2>Hello from LRWP</H2>\nCount = ' + str(count))
        req.out.write('\n</BODY></HTML>\n')
        req.finish()

    lrwp.close()

if __name__ == '__main__':
    main()

Quote:
> I'd love to use something like Medusa if I could figure
> out how to get it to support CGIs.  I really don't want to use a
> 'large' server like Apache, since I'm really just trying to run a
> lightweight server.

> Any advice would be GREATLY appreciated!!!

I'm sure you can get CGIHTTPServer to work.  But it might
not be quite as lightweight as Xitami+LRWP... give it a try!

Alex



Sun, 16 Nov 2003 22:15:39 GMT  
 Small, Local Web/CGI Server Advice

Quote:

> I'm sure you can get CGIHTTPServer to work.  But it might
> not be quite as lightweight as Xitami+LRWP... give it a try!

If we are already talking about long-running apps the easiest thing
is to derive from SimpleHTTPServer.SimpleHTTPRequestHandler.

Sloth, if you have the chance to design your web apps from the
ground up do not make the mistake to use print or other stupid
things to write the HTML output hard-wired to stdout. This is a
mistake most people (including me) are doing in the beginning.

Once the web application uses file objects for in, out, err and an
arbitrary dictionary as environment you can write small wrappers
with a few lines for nearly everything (stand-alone, FastCGI,
mod_python etc., LRWP).

Ciao, Michael.



Mon, 17 Nov 2003 00:38:38 GMT  
 Small, Local Web/CGI Server Advice

Quote:

> i agree w/ the other poster that Medusa is the better choice,

IMHO it depends. AFAIK the web application has to behave well.
Therefore it does not make sense to deploy Medusa if your
application has to wait for long-lasting blocking I/O operations
(like slow database connection with only synchronous API calls).

And AFAIK using traditional CGI-BIN programs also needs forking
under Medusa. You're lost on Win98...

Or did I get something wrong?

Ciao, Michael.



Mon, 17 Nov 2003 00:43:36 GMT  
 Small, Local Web/CGI Server Advice

Quote:

> IMHO it depends. AFAIK the web application has to behave well.
> Therefore it does not make sense to deploy Medusa if your
> application has to wait for long-lasting blocking I/O operations
> (like slow database connection with only synchronous API calls).

There is a way around the issue, according to Sam Rushing. See his
comments on the http://yahoogroups.com/group/medusa/messages/

Quote:
> And AFAIK using traditional CGI-BIN programs also needs forking
> under Medusa. You're lost on Win98...

So don't use traditional cgi-bin programs under Medusa, use
Bobo instead (my private copy is at
http://www.lrz.de/~ui22204/medusatest.tgz )


Mon, 17 Nov 2003 01:11:26 GMT  
 Small, Local Web/CGI Server Advice

Quote:

> So don't use traditional cgi-bin programs under Medusa, use
> Bobo instead

Yes, I know. But the original poster might be stuck with already
existing traditional CGI-BIN programs.

Ciao, Michael.



Mon, 17 Nov 2003 02:39:17 GMT  
 Small, Local Web/CGI Server Advice

Quote:


> > IMHO it depends. AFAIK the web application has to behave well.
> > Therefore it does not make sense to deploy Medusa if your
> > application has to wait for long-lasting blocking I/O operations
> > (like slow database connection with only synchronous API calls).

> There is a way around the issue, according to Sam Rushing. See his
> comments on the http://yahoogroups.com/group/medusa/messages/

Are you referring to
http://groups.yahoo.com/group/medusa/message/299 ? IMHO this is
another case where the data is already ready to be sent to the
client. I was talking about the situation where collecting the data
is taking some time. E.g. in my case doing LDAP queries takes some
time and the LDAP API does not really provide a way of implementing
it completely event-driven like mentioned there.

Ciao, Michael.



Mon, 17 Nov 2003 02:45:06 GMT  
 Small, Local Web/CGI Server Advice
I realize the post below is probably more than you are interested in, but it
seems like a good time to bring up these issues since I've been working with
CGIHTTPServer.py intensively over the last week.

First of all, I think versions prior to 2.x didn't work at all on Windows,
at least that is what I gather from previous posts. The version that I'm
using with ActiveState Python 2.1 (build 210) works with some caveats:
1. If you want to run CGIs in directories other than the defaults (/cgi-bin
and /htbin) then you'll have to create a subclass and override the
cgi_directories list, but if you want to actually support Python scripts in
any directory such as /somecgi.py then you have to change the logic
currently used to determine whether a request is a CGI or not (more on this
later).
2. If you want to support extensions other than .py and .pyw such as .cgi
then you have to override is_python. I don't know if compiled scripts (.pyc)
are supported or if that requires a more elaborate wrapper?!
3. In order to correctly support binary output and avoid proper pipe
buffering issues under Windows the source needs to be fixed. I submitted
this to sourceforge at
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=427345&gr...
5470
My patch seems to take care of the problem with binary uploads, but I would
like to see more tests before it is committed as an official fix.
4. There is a very odd interaction between IE 5.x and CGIHTTPServer.py that
causes POSTs to fail, but in a very strange way. After the first GET or POST
request, subsequent POSTs will result in IE automatically doing a second
POST and then IE will report a DNS error for the page, or if the POST
response is very long IE will do a GET on the request URL rather than
failing with a DNS error. I'm still investigating this along with Mark Lutz,
but my guess is someone who understands the underlying popen2 ans
SocketServer source... is going to have to debug this one. The problem is
almost certainly socket-related.
5. CGIHTTPServer.py and BaseHTTPServer.py currently only support HTTP/1.0.
In addition, there is no support for automatically generating a
Content-length, there are likely a number of security holes and there are
definitely performance issues, so at this point I wouldn't recommend using
CGIHTTPServer.py except for teaching, learning and development, preferably
behind a firewall that doesn't give access to the port the server is running
on. However, I would like to see the library upgraded enough to be secure
and an effective alternative to using Apache, IIS, Zope, etc for "personal"
servers, so I hope to contribute to CGIHTTPServer.py ... towards this end.
One simple upgrade I want is to limit accepting requests by IP which would
make it easy to limit requests to only localhost (127.0.0.1)

I have rewritten CGIHTTPServer.py to simplify issues 1 and 2 when
subclassing and also fixes issue 3, but I'm waiting until further testing is
done before submitting it as a replacement.

ka


Quote:
> I'm attempting to create my first major Python app for a company that
> wants to run Web (HTML) pages and CGI scripts on their salespeople's
> laptop computers.  Basically, the salesperson would run a local Web
> server that allows for basic CGI scripts to be run.  The customer is
> pushing hard that they want to use their Web browser as the client and
> to have a local server serving CGI/HTML that also is running on that
> laptop (that wouldn't have been my first choice, but those are the
> constraints I'm working with...)

> I've tried to use CGIHTTPServer, but I am having problems getting that
> to work on Windows ME/98 (using ActiveState Python 2.1 - HTML is
> served just fine, but CGIs cause EXPLORER to crash).  Any advice on a
> small, preferably Python based Web server that I can run that will
> support CGI?  I'd love to use something like Medusa if I could figure
> out how to get it to support CGIs.  I really don't want to use a
> 'large' server like Apache, since I'm really just trying to run a
> lightweight server.

> Any advice would be GREATLY appreciated!!!

> Thanks,

> Jeremy.



Mon, 17 Nov 2003 02:59:14 GMT  
 Small, Local Web/CGI Server Advice

Quote:

> I realize the post below is probably more than you are interested in, but it
> seems like a good time to bring up these issues since I've been working with
> CGIHTTPServer.py intensively over the last week.

> First of all, I think versions prior to 2.x didn't work at all on Windows,
> at least that is what I gather from previous posts. The version that I'm
> using with ActiveState Python 2.1 (build 210) works with some caveats:
> 1. If you want to run CGIs in directories other than the defaults (/cgi-bin
> and /htbin) then you'll have to create a subclass and override the
> cgi_directories list, but if you want to actually support Python scripts in
> any directory such as /somecgi.py then you have to change the logic
> currently used to determine whether a request is a CGI or not (more on this
> later).
> 2. If you want to support extensions other than .py and .pyw such as .cgi
> then you have to override is_python. I don't know if compiled scripts (.pyc)
> are supported or if that requires a more elaborate wrapper?!
> 3. In order to correctly support binary output and avoid proper pipe
> buffering issues under Windows the source needs to be fixed. I submitted
> this to sourceforge at
> http://sourceforge.net/tracker/?func=detail&atid=105470&aid=427345&gr...
> 5470
> My patch seems to take care of the problem with binary uploads, but I would
> like to see more tests before it is committed as an official fix.
> 4. There is a very odd interaction between IE 5.x and CGIHTTPServer.py that
> causes POSTs to fail, but in a very strange way. After the first GET or POST
> request, subsequent POSTs will result in IE automatically doing a second
> POST and then IE will report a DNS error for the page, or if the POST
> response is very long IE will do a GET on the request URL rather than
> failing with a DNS error. I'm still investigating this along with Mark Lutz,
> but my guess is someone who understands the underlying popen2 ans
> SocketServer source... is going to have to debug this one. The problem is
> almost certainly socket-related.
> 5. CGIHTTPServer.py and BaseHTTPServer.py currently only support HTTP/1.0.
> In addition, there is no support for automatically generating a
> Content-length, there are likely a number of security holes and there are
> definitely performance issues, so at this point I wouldn't recommend using
> CGIHTTPServer.py except for teaching, learning and development, preferably
> behind a firewall that doesn't give access to the port the server is running
> on. However, I would like to see the library upgraded enough to be secure
> and an effective alternative to using Apache, IIS, Zope, etc for "personal"
> servers, so I hope to contribute to CGIHTTPServer.py ... towards this end.
> One simple upgrade I want is to limit accepting requests by IP which would
> make it easy to limit requests to only localhost (127.0.0.1)

> I have rewritten CGIHTTPServer.py to simplify issues 1 and 2 when
> subclassing and also fixes issue 3, but I'm waiting until further testing is
> done before submitting it as a replacement.

> ka



> > I'm attempting to create my first major Python app for a company that
> > wants to run Web (HTML) pages and CGI scripts on their salespeople's
> > laptop computers.  Basically, the salesperson would run a local Web
> > server that allows for basic CGI scripts to be run.  The customer is
> > pushing hard that they want to use their Web browser as the client and
> > to have a local server serving CGI/HTML that also is running on that
> > laptop (that wouldn't have been my first choice, but those are the
> > constraints I'm working with...)

> > I've tried to use CGIHTTPServer, but I am having problems getting that
> > to work on Windows ME/98 (using ActiveState Python 2.1 - HTML is
> > served just fine, but CGIs cause EXPLORER to crash).  Any advice on a
> > small, preferably Python based Web server that I can run that will
> > support CGI?  I'd love to use something like Medusa if I could figure
> > out how to get it to support CGIs.  I really don't want to use a
> > 'large' server like Apache, since I'm really just trying to run a
> > lightweight server.

> > Any advice would be GREATLY appreciated!!!

> > Thanks,

> > Jeremy.

Kevin:

I would LOVE to be able to just subclass CGIHTTPServer and get it to
respond to GET requests.  For some odd reason, that causes Win ME to
fail (at least on this system).  I cannot access your post on
SourceForge, but I have a feeling that we are running into similar
issues.

Thanks to all for the advice!  Anyone had any experience with WebWare?

Jeremy.



Mon, 17 Nov 2003 06:17:17 GMT  
 
 [ 13 post ] 

 Relevant Pages 

1. Suggestions for local Ruby Web/CGI Processing

2. Web server: local VS remote...script not interpreted

3. Need advice: serving data using http/web-server to clients ( not only browsers )

4. Small Business web servers

5. World's Smallest Web Server

6. Error 1026 How To Build the G Web Server Using CGI Into an Executable

7. COBOL CGI/Windows2000 Web Server

8. CGI problems on new web server

9. Q: secure parameter passing to python CGI script on web server

10. CGI problems in Personal Web Server

11. CGI scripts in Python on MicroSofts Personal web server

12. CGI scripts in Python on MicroSofts Personal web server

 

 
Powered by phpBB® Forum Software