Skip to main content

Common Flask Utilities

Project description

common flask utils

This utils is use some of python package to enhance flask.Flask.

All of this usage you can see in flask

requirement

Use following libraries to enhance Flask.

  • flask-sqlalchemy

    Is a extension for Flask that adds support for SQLAlchemy to your application. It aims to simplify using SQLAlchemy with Flask by providing useful defaults and extra helpers that make it easier to accomplish common tasks.

  • python-i18n

    This library provides i18n functionality for Python3 out of the box. The usage is mostly based on Rails i18n library.

  • pyjwt

    This library provides jwt token for Python3. Python implementation of RFC 7519

  • flask-cors

    A Flask extension for handling Cross Origin Resource Sharing(CORS), making cross-origin AJAX possible.

installation

pip install common-flask-utils

usage

base usage

from common_utils import Flask

app: Flask = Flask(__name__)
app.run()

auto register blueprint

from common_utils import Flask
app: Flask = Flask(__name__, controller_scan_dir = "app.modules")
app.run()

or

from common_utils import Flask, blueprint_registration
app: Flask = Flask(__name__)
blueprint_registration(app, blueprint_dir="app.modules")
app.run()

you should use Outlining to init controller like blueprint and place it inside modules package.

like:

# app/modules/controller.py 
controller: Outlining = Outlining("Root", __name__, url_prefix="/root")

@controller.get("")
def index():
    return "root page"

after that, you can visit webpage use url like: http://localhost:5000/root, if you are not change host and port in config or pass it through app.run()

if inside app.modules you have sub package, like:

# app/modules/v1/controller.py
controller: Outlining = Outlining("Root", __name__, url_prefix="/root")

@controller.get("")
def index():
    return "root page"

then you can visit webpage use url like: http://localhost:5000/v1/root

auto blueprint registration is provide by method @see: blueprint_registration in side common_utils/utils/blueprint_util.py

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

common_flask_utils-0.1.5.tar.gz (17.3 kB view hashes)

Uploaded Source

Built Distribution

common_flask_utils-0.1.5-py3-none-any.whl (19.7 kB view hashes)

Uploaded Python 3

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