Skip to main content

A simple Flask extension to manage URL patterns. In a Django kind of way.

Project description

Flask URL Patterns

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)

Project details


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.2.tar.gz (2.1 kB view details)

Uploaded Source

Built Distribution

flask_url_patterns-0.1.2-py3-none-any.whl (3.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flask_url_patterns-0.1.2.tar.gz
  • Upload date:
  • Size: 2.1 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.2.tar.gz
Algorithm Hash digest
SHA256 067f38dd0e2df6b5fcff1d8090005baecc64652db7f00e871ebb7d6a1164ea37
MD5 4f4c295411e073e6ef21f045e7a66475
BLAKE2b-256 42218f5b40e78d1fb0dcd724155f923eb1da169a8d46f80dc2afac8af4b3cdde

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: flask_url_patterns-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 3.1 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d595b1d0cf8ef2ac4f85d7477eef21ad041e15f72edcb718edc356c4bd6f331f
MD5 bafeb305d787481ad6a22e4e77443443
BLAKE2b-256 9f925211836f0c349501cd31f376a4e031f4804d284ca63bb5357250dea4f32b

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page