Skip to main content

Flask URL Patterns

Usage

You must instanciate UrlPatterns and provide the urlpatterns param to it as well as a Flask app instance either in __init__ or init_app params.

urlpatterns must be of type: Iterable[URLPattern] with:

class URLPattern(TypedDict):
    path: str | Iterable[str]
    name: NotRequired[str]
    view: NotRequired[RouteCallable]
    children: NotRequired[Iterable[URLPattern]]
    options: NotRequired[dict[str, Any]]
    parent_vars_rename: NotRequired[dict[str, str]]

(In case typing is not up to date in README.md, know that you can see current accepted typing in flask_url_patterns.typing)

Example

from flask import Flask
from flask_url_patterns import URLPatterns

from . import views

app = Flask(__name__)

urlpatterns = UrlPatterns(urlpatterns=[
    {
        "path": "/",
        "name": "index",
        "view": views.index,
        "children": [
            {
                "path": "/api",
                "name": "api",
                "children": [
                    {
                        "path": "/resources",
                        "view": views.ResourceViewSet.as_view({ # Using as implemented by [Flask-ViewSets](https://pypi.org/project/Flask-Viewsets/)
                            "get": "list",
                            "post": "create",
                        }),
                        "children": [
                            {
                                "path": "/<int:id>",
                                "view": views.ResourceViewSet.as_view({
                                    "get": "retrieve",
                                    "put": "update",
                                    "patch": "partial_update",
                                    "delete": "destroy",
                                }),
                            },
                        ],
                    },
                ]
            },
        ],
    },
])

urlpatterns.init_app(app)

Metadata

Release files for Flask-Url-Patterns 0.1.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for Flask-Url-Patterns 0.1.3
File Size Uploaded
flask_url_patterns-0.1.3.tar.gz 2.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for Flask-Url-Patterns 0.1.3
File Interpreter ABI Platform
flask_url_patterns-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 7.0 kB

Release files / flask_url_patterns-0.1.3.tar.gz

Download URL flask_url_patterns-0.1.3.tar.gz
Size 2.9 kB
Tags Source
SHA-256 checksum
How to use checksums
4873d2acf266d1123c476ea3602c058b394b22a2a758272dff251887af6d5814
BLAKE2b-256 checksum
How to use checksums
8bc55f39d86c6e145d5d527814aef4fa5cfcbf7ba5917233efbebd2cbc24d5db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.2 Linux/5.15.153.1-microsoft-standard-WSL2

Release files / flask_url_patterns-0.1.3-py3-none-any.whl

Download URL flask_url_patterns-0.1.3-py3-none-any.whl
Size 4.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d071f528edcb8b0f082a50dc968a530cc301dff0293fe1985a0ac67b78ed65bc
BLAKE2b-256 checksum
How to use checksums
71da965f224a933495f5ce79bf9623127fc3edc08ec7632cd880b4c114c7d547
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.11.2 Linux/5.15.153.1-microsoft-standard-WSL2

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page