Nevow - 小型Python Web框架


未知
未知
Python

软件简介

Nevow 是一个用 Python 写的用来构建web应用程序的工具。

代码有如:

######################################################################  
# Run using 'twistd -noy file.tac', then point your browser to  
# http://localhost:8080  
# A very simple Nevow site.  
# Don't do it this way. Better ways are coming.  
######################################################################

from twisted.application import service, internet

from nevow               import appserver  
from nevow               import rend

class MyPage ( rend.Page ):

    def renderHTTP ( self, ctx ):  
        html = \  
             '' + \  
             '"Nevow Tutorial"' + \  
             'Hi there'  
        return html

######################################################################  
# Nevow Boilerplate  
######################################################################

application = service.Application ( "nevowdemo1" )  
port        = 8080  
res         = MyPage()  
site        = appserver.NevowSite ( res )  
webService  = internet.TCPServer ( port, site )  
webService.setServiceParent ( application )