Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for froi, version 0.4.7
Filename, size File type Python version Upload date Hashes
Filename, size froi-0.4.7-py3-none-any.whl (5.0 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size froi-0.4.7.tar.gz (3.7 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page