A Flask wrapper to easily handle routes defined as Python native objects
Project description
A wrapper for Flask’s native routing as a form of template. Routes will be defined as objects to easily define domains.
# Inside some route object
from froi import Froi
class SomeRoute(Froi):
def __init__(self, app):
super().__init__(app, 'SomeRoute', '/some_route')
def install(self):
# define a get route on base
self.setget().route(func=sample_fxn_1)
# define a post
self.setpost().route('/do_something', func=sample_fxn_2)
# define a put
self.setput().route('/edit_something', func=sample_fxn_3)
# define a delete
self.setdelete().route('/delete_something', func=sample_fxn_4)
# Inside your server handler
from flask import Flask
from some_route import SomeRoute
app = Flask(config.APP_NAME)
SomeRoute(app).install()
app.run()
If you want a RESTful pattern to handle the routes, you can omit defining the install function.
from froi import Froi
class SomeRoute(Froi):
def __init__(self, app):
super().__init__(app, 'SomeRoute', '/some_route')
def get(self):
... do something
def post(self):
... do something
This will automatically create the defined GET, POST, PUT, and DELETE endpoints.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
froi-0.4.7.tar.gz
(3.7 kB
view details)
Built Distribution
froi-0.4.7-py3-none-any.whl
(5.0 kB
view details)
File details
Details for the file froi-0.4.7.tar.gz
.
File metadata
- Download URL: froi-0.4.7.tar.gz
- Upload date:
- Size: 3.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.6.8 Darwin/19.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de2f05fb21a0133d8dbb4a65a7842e2b76a38363cee2a3a8ee47748cdca1e7c1 |
|
MD5 | 61b34d498c398a0b4ea47c230a6935db |
|
BLAKE2b-256 | 324868fdfdff182b2b52806fa6c17040ed8aa20d8a00f365fcca83cb779144ba |
File details
Details for the file froi-0.4.7-py3-none-any.whl
.
File metadata
- Download URL: froi-0.4.7-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/0.12.17 CPython/3.6.8 Darwin/19.2.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 453bd5792a8e4730a8dc0b751b59d815b33a83ac4968f23dff1871a08afe6005 |
|
MD5 | be48906f6dc50869ed08f9289abac2df |
|
BLAKE2b-256 | d85a41cb2ef359e35159b220d25b91f1a5db4dbbfbd52992200777705f0aea22 |