File: complex_routing.py

package info (click to toggle)
python-werkzeug 1.0.1%2Bdfsg1-2%2Bdeb11u1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 2,888 kB
  • sloc: python: 21,897; javascript: 173; makefile: 36; xml: 16
file content (43 lines) | stat: -rw-r--r-- 1,281 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
from werkzeug.routing import EndpointPrefix
from werkzeug.routing import Map
from werkzeug.routing import Rule
from werkzeug.routing import Subdomain
from werkzeug.routing import Submount

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"),
                            ],
                        ),
                    ],
                )
            ],
        ),
    ]
)