Skip to main content

Straightforward file-based routing extension for Flask. Introduces the concepts of pages to Flask.

Project description

FlaskFSRouter



Straightforward file-based routing extension for Flask. Introduces the concepts of pages to Flask.


Getting Started

pip install flask_fs_router


Initialize the extension.
from flask import Flask
from flask_fs_router import FlaskFSRouter

app = Flask(__name__)
FlaskFSRouter(app)

Pages are python files with a default function defined. These pages are stored in the /pages directory of your project, it is automatically available as a route based on its filename.

Create an example index route.

pages/index.py

def default():
    return "Home page"

Conventions

Index Pages

The index file of any folder is the name of that folder.

pages/ecommerce/index.py              ->         oursite.com/ecommerce     |  GET
pages/products/index.py               ->         oursite.com/products      |  GET

Static Routes



pages/index.py              ->        oursite.com/          |  GET
pages/about.py              ->        oursite.com/about     |  GET
pages/about/index.py        ->        oursite.com/about     |  GET
pages/about/me.py           ->        oursite.com/about/me  |  GET
pages/posts/1.py            ->        oursite.com/posts/1   |  GET
pages/posts/[post_id].py    ->        oursite.com/posts/<post_id>  |  GET

Request Methods

By default, pages map to GET requests. To change this behavior, define request methods within the file name using parentheses.

Example: Request methods

pages/posts/create_post(post).py            ->        oursite.com/posts/create-post  |  POST

Github Page

https://github.com/JarriqTheTechie/flask_fs_router

Contributing

We love the idea of a community. We'll be putting together a contribution guide in the near future.

License

flask_fs_router is available as open source under the terms of the MIT License http://opensource.org/licenses/MIT

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-fs-router-1.1.3.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

flask_fs_router-1.1.3-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file flask-fs-router-1.1.3.tar.gz.

File metadata

  • Download URL: flask-fs-router-1.1.3.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for flask-fs-router-1.1.3.tar.gz
Algorithm Hash digest
SHA256 4ceac8f45b099d50aa0b93acdc33e59c67569a64b5f1ca5da640d2981de12090
MD5 61114a295efbe0e2d5d547890ae0dddd
BLAKE2b-256 4fcedba824e95e147994548dbbdc4e5c8f152c58d42d9b04efd5511d62a4d4f3

See more details on using hashes here.

File details

Details for the file flask_fs_router-1.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for flask_fs_router-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 722e5e87b908cb957c2dbd0536d6dd0c467e2fa74929b982cd25d4f507df4ca7
MD5 412a6d4390173889ed531823f4ac3f2a
BLAKE2b-256 b67bbbdb6072dabfdb0b31fe858f733308a78d5f194a9d4c8abddf3328240dc0

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