File: complex_routing.py

package info (click to toggle)
python-werkzeug 0.8.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,940 kB
  • sloc: python: 16,194; makefile: 143; pascal: 66; xml: 16
file content (19 lines) | stat: -rw-r--r-- 595 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from werkzeug.routing import Map, Rule, Subdomain, Submount, EndpointPrefix

m = Map([
    # Static URLs
    EndpointPrefix('static/', [
        Rule('/', endpoint='index'),
        Rule('/about', endpoint='about'),
        Rule('/help', endpoint='help'),
    ]),
    # Knowledge Base
    Subdomain('kb', [EndpointPrefix('kb/', [
        Rule('/', endpoint='index'),
        Submount('/browse', [
            Rule('/', endpoint='browse'),
            Rule('/<int:id>/', defaults={'page': 1}, endpoint='browse'),
            Rule('/<int:id>/<int:page>', endpoint='browse')
        ])
    ])])
])