This release is a pre-release and may not be stable for production use.
Flouter
Flouter (Flask Router) is a convenience add-on for the Flask library. It converts a directory structure into valid routes for a Flask application. This allows developers to quickly layout complex applications, and easily navigate to existing code. This library is under heavy development and may not yet support a feature you need. If that is the case, please submit a feature request so the library can continue to improve.
Installing
Install and update using pip:
pip install -U flouter
Basic Usage
Flouter will convert the following routes directory structure…
routes/
|-- api/
|-- index.py
|-- echo.py
|-- _foo.py
…to the corresponding routes in a flask application.
/api/
/api/echo/
/api/<foo>
In one of these files, methods are defined by simple named functions that are called when the appropriate HTTP request is passed to the route.
# echo.py
def get():
return 'Hello World'
def post(request):
# returns are turned into valid responses by the library
return request.json
An example usage of this library is included in examples/basic
# main.py
import os
from flask import Flask
from src.flouter import Router
app = Flask(__name__)
route_dir = os.getcwd() + "/routes/"
router = Router(route_dir)
router.register_routes(app)
app.run()
A Router object also allows route_params to be defined, which allow methods to access important elements of an application without having to explicitly import these into every single file, which could quickly become annoying. The default value for this dictionary contains only the flask.request object, which you can access in any function by adding the request kwarg. However, you can extend this to pass in any important variables you may have.
# main.py
d = dict(
my_constant=10,
)
router = Router(directory, route_params=d)
Which enables my_constant to be passed to any route child function.
# /api/index.py
def get(my_constant):
return my_constant
Metadata
Release files for flouter 0.0.6.dev0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| flouter-0.0.6.dev0.tar.gz | 6.7 kB | Without provenance | Details for flouter-0.0.6.dev0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| flouter-0.0.6.dev0-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for flouter-0.0.6.dev0-py2.py3-none-any.whl |
Total release size: 14.2 kB
Release files / flouter-0.0.6.dev0.tar.gz
| Download URL | flouter-0.0.6.dev0.tar.gz |
|---|---|
| Size | 6.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5f12d0895b02fc3f82846e00bdf74dd1187ea2bd96a4152bbf24c81feede8621
|
|
BLAKE2b-256 checksum How to use checksums |
cb74ef119c16e141b5115a55fc873b328e97565da7641cd56231f8e57b8ee262
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.9
|
Release files / flouter-0.0.6.dev0-py2.py3-none-any.whl
| Download URL | flouter-0.0.6.dev0-py2.py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
9182d998fe345a990e741529a92b404a13ca0a648a617b1c35b923c3c646aa62
|
|
BLAKE2b-256 checksum How to use checksums |
5c2622c8635af8079064aea7ac27a91bffd7344ad11796a920ba8ae8dc600a0b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.14.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.35.0 CPython/3.6.9
|
Security for flouter 0.0.6.dev0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.