webpy 配置子应用(站点)

In blog.py:

import web
urls = (
  "", "reblog",
  "/(.*)", "blog"
)

class reblog:
    def GET(self): raise web.seeother('/')

class blog:
    def GET(self, path):
        return "blog " + path

app_blog = web.application(urls, locals())

In your main code.py:

import web
import blog
urls = (
  "/blog", blog.app_blog, #注意,此处是没有引号的
  "/(.*)", "index"
)

class index:
    def GET(self, path):
        return "hello " + path

app = web.application(urls, locals())

if __name__ == "__main__":
    app.run()


In your browser:
http://youdomain/blog

posted on 2013-09-23 11:20  一个石头  阅读(227)  评论(0)    收藏  举报