Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

49 lines (34 sloc) 0.887 kB
layout title
default
Utiliser les sous-applications

Utiliser les sous-applications

Autre langages: english | ...

Probleme

Comment inclure une application définie dans un autre fichier dans votre application principale ?

Solution

Dans 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())

Dans votre application principale 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()
Jump to Line
Something went wrong with that request. Please try again.