Skip to content

Commit

Permalink
edit
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsw authored and anandology committed Jan 5, 2011
1 parent 255973c commit 1dca360
Showing 1 changed file with 34 additions and 13 deletions.
47 changes: 34 additions & 13 deletions cookbook/subapp.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,38 @@ title: using subapplications

# using subapplications

## Problem

class blog:
def GET(self, path):
return "blog " + path
app_blog = web.application(urls, locals())
urls = (
"/blog", app_blog,
"/(.*)", "index"
)
class index:
def GET(self, path):
return "hello " + path
app = web.application(urls, locals())
How do you include an application defined in another file in your application?

## Solution

In `blog.py`:

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 blog
urls = (
"/blog", blog.app_blog,
"/(.*)", "index"
)

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

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

0 comments on commit 1dca360

Please sign in to comment.