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)

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask_url_patterns-0.1.3.tar.gz (2.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flask_url_patterns-0.1.3-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file flask_url_patterns-0.1.3.tar.gz.

File metadata

  • Download URL: flask_url_patterns-0.1.3.tar.gz
  • Upload date:
  • Size: 2.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.2 Linux/5.15.153.1-microsoft-standard-WSL2

File hashes

Hashes for flask_url_patterns-0.1.3.tar.gz
Algorithm Hash digest
SHA256 4873d2acf266d1123c476ea3602c058b394b22a2a758272dff251887af6d5814
MD5 09c500e99d71d8be668819dea1c74ba6
BLAKE2b-256 8bc55f39d86c6e145d5d527814aef4fa5cfcbf7ba5917233efbebd2cbc24d5db

See more details on using hashes here.

File details

Details for the file flask_url_patterns-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: flask_url_patterns-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.2 Linux/5.15.153.1-microsoft-standard-WSL2

File hashes

Hashes for flask_url_patterns-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 d071f528edcb8b0f082a50dc968a530cc301dff0293fe1985a0ac67b78ed65bc
MD5 16a425b304a8848ae92b9edb183e8f9e
BLAKE2b-256 71da965f224a933495f5ce79bf9623127fc3edc08ec7632cd880b4c114c7d547

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.3 This release

2 files

0.1.2

2 files

0.1.1

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page