Using Python for Web development

Brian Zhou brian_zhouNOSPAM at agilent.com
Mon Feb 12 12:45:36 EST 2001


<billy_bill_1 at my-deja.com> wrote in message
news:967og3$7hl$1 at nnrp1.deja.com...

> hoping!  Oh and that Servlet in Jpython, would that be like JSP and
> servlets with no type checking crap?
>

Here's a "Hello world!" servlet in jython:

########### ><8
import sys, java, javax

class hello(javax.servlet.http.HttpServlet):
    def doGet(self, request, response):
        response.setContentType("text/html")
        out = response.getOutputStream()

        out.println("""\
<html>
<head><title>Hello World</title></head>
<body>Hello World!
<P>
Current server time is: %s<br>
</P>
</body>
</html>
""" % (java.util.Date()))

        return
########### ><8

It's pretty much like mod_python, only using servlet API instead of CGI.
With java stuff like JDBC all available, it gets best of both worlds.
Personally I don't like embed HTML markup in python code, there're template
systems out there that you can use with mod_python or jython.

Regards,

/Brian





More information about the Python-list mailing list