1、urls一般都说多路由,我认为这个其实就是改变http不通的请求从而得到不同服务端程序的响应,从而将业务细化
2、代码示例
#coding:utf-8
import web
#urls rule
urls=(
"/(demo2.*)","demo1",
"/(demo1.*)","demo2"
)
#application information
app=web.application(urls,globals())
class demo1:
def GET(self, arg1):
web.header('Content-Type','text/html;charset=UTF-8')
return '1111111,'+'11111111'+'!'
print "this is application demo1"
class demo2:
def GET(self, arg1):
web.header('Content-Type', 'text/html;charset=UTF-8')
return '22222222222,' + '222222222222' + '!'
print "this is application demo2"
if __name__ == "__main__":
app.run()
3、说明
通过运行127.0.0.1:8000/demo1则响应内容为demo2类中内容
通过运行127.0.0.1:8000/demo2则响应内容为demo1类中内容