A flask encapsulated based on personal habits for fast use.
Project description
FourCats-Flask
Statement
FourCats-Flask
is a module with personal habits based onFlask
andFlask-RESTX
encapsulation. The main purpose of encapsulation is to provide a more convenient initialization method for partners.
Simple Example
Init Flask
- The encapsulated flask object package contains JSON serialization processing, which has overloaded the request function.
from fourcats_flask import Flask
flask_app = Flask(__name__)
if __name__ == '__main__':
flask_app.run(host="localhost", port=5051, debug=True)
Init All Plug-in
from fourcats_flask import Api
from fourcats_flask import Flask, FlaskInit
flask_app = Flask(__name__)
api = Api(title="Flask Base", description="Flask Base Document", doc="/api/docs")
# create_all - Whether to create a data table through Flask-Sqlalchemy. The default is false.
FlaskInit(api=api, configs=["<your_path>/setting"], create_all=True).init_app(app=flask_app)
# or
FlaskInit.register_hook(app=flask_app, api=api)
FlaskInit.register_config(configs=["<your_path>/setting"], app=flask_app)
FlaskInit.register_sqlalchemy(app=flask_app, create_all=True)
Use Token
from fourcats_flask import Token
auth = Token(secret="secret", scheme="JWT", algorithm="H265", message="Authentication failed.")
# with permission
# Using this decorator, the method will be called to execute the corresponding permission processing after the token passes the verification.
@auth.verify_permission
def verify_permission(user):
# do something
_ = user
pass
About better function
Completion example
Please click to view the completed sample code.
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
fourcats-flask-0.1.1.tar.gz
(14.5 kB
view hashes)
Built Distribution
Close
Hashes for fourcats_flask-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c8f2c00b70fa219a8bca3022112c9a75c0d42107ee39bf3092d13e196630ff2 |
|
MD5 | f9b99ddc7adb7bb32edb35dd12443e51 |
|
BLAKE2b-256 | f040f704de2c8ede0abbb89281ba4ef33bd323001609f2b76660d9492ea5d5ac |