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

Uploaded Source

Built Distribution

flask_url_patterns-0.1.0-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: flask_url_patterns-0.1.0.tar.gz
  • Upload date:
  • Size: 1.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.0.tar.gz
Algorithm Hash digest
SHA256 695331dd00faaab8f957a35b203cd8dd5e5a0893770c2e38a6f0ad998431c680
MD5 487d35e0ddabcc65c6fc47c8239e6b31
BLAKE2b-256 da0aa631da8f72d6936d215cf1aa911423271688f7fa536ccdde4bf44001434f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: flask_url_patterns-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 2.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7cedde7b906a34d05178c2a0ababa16935cf007b82c8f511b7a1c2864d4de12e
MD5 11a70677377a7e32fed0cdf4fbf939d4
BLAKE2b-256 c005ff7b69c59767697200ea762177512d8fcedfb180495b29fddcb6b3ee508c

See more details on using hashes here.

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