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 object 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.get().route(view_func=sample_fxn_1)
# define a post
self.post().route('/do_something', view_func=sample_fxn_2)
# define a put
self.put().route('/edit_something', view_func=sample_fxn_3)
# define a delete
self.delete().route('/delete_something', view_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')
This will automatically create a GET, POST, PUT, and DELETE endpoints.
This feature though is a work in progress and may not work as expected.
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.1.2.tar.gz
(3.2 kB
view hashes)
Built Distribution
froi-0.1.2-py3-none-any.whl
(6.5 kB
view hashes)