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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file common_flask_utils-0.1.5.tar.gz.

File metadata

  • Download URL: common_flask_utils-0.1.5.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.2

File hashes

Hashes for common_flask_utils-0.1.5.tar.gz
Algorithm Hash digest
SHA256 c90696b0bc1a1757f35c2ba8a1259f5541208f8488abd059681d1eff4faf2c0b
MD5 16683bc0b73aa130028f28c2c2e1e7e1
BLAKE2b-256 27e39b8ee9237f84f846bdff3bf91c74e2b8127866eaff3cbafe04a6ee085e4c

See more details on using hashes here.

File details

Details for the file common_flask_utils-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for common_flask_utils-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 26ca6268473d21625516572ea23f139aef41342300bc8b80e0ebf1e9ad4b1e68
MD5 29a80b842b32b0a35dbec928105e927d
BLAKE2b-256 8017d7f375dceee6c2ecbbcd0f3a7fde730b73c87878d2baa666944168a5a082

See more details on using hashes here.

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