- 使用子应用
- 问题
- 解法
使用子应用
问题
如何在当前应用中包含定义在其他文件中的某个应用?
解法
在blog.py中:
import weburls = ("", "reblog","/(.*)", "blog")class reblog:def GET(self): raise web.seeother('/')class blog:def GET(self, path):return "blog " + pathapp_blog = web.application(urls, locals())
当前的主应用code.py:
import webimport blogurls = ("/blog", blog.app_blog,"/(.*)", "index")class index:def GET(self, path):return "hello " + pathapp = web.application(urls, locals())if __name__ == "__main__":app.run()
