Skip to main content

flask-controller

PyPI PyPI - Downloads PyPI - Python Version PyPI - License

简介

flask-controller 简化Flask开发,自动路由注册,以类的形式管理控制器

支持多层扫描

安装

pip install flask-controller

使用示例

项目结构

.
└── flask_app
    ├── controllers
    │   ├── __init__.py
    │   ├── admin
    │   │   ├── __init__.py
    │   │   └── login_controller.py
    │   ├── index_controller.py
    │   └── user_controller.py
    └── main.py

文件内容

flask_app/controllers/index_controller.py

# -*- coding: utf-8 -*-
from flask_controller import FlaskController


class IndexController(FlaskController):

    def index(self):
        return 'index'

flask_app/controllers/user_controller.py

# -*- coding: utf-8 -*-
from flask_controller import FlaskController


class UserController(FlaskController):

    def user_name(self, name, age: int = 23):
        return 'username'

flask_app/controllers/admin/login_controller.py

# -*- coding: utf-8 -*-
from flask_controller import FlaskController


class LoginController(FlaskController):
    def index(self):
        return 'Login index'

flask_app/main.py

# -*- coding: utf-8 -*-


from flask import Flask

from flask_controller import FlaskControllerRegister

app = Flask(__name__, static_folder=None)


# 自动注册路由
register = FlaskControllerRegister(app)

register.register_package('flask_app.controllers')

注册结果

Map([
 <Rule '/admin/login/index' (OPTIONS, GET, HEAD, POST) -> admin.login.index>,
 <Rule '/index/index' (OPTIONS, GET, HEAD, POST) -> index.index>,
 <Rule '/user/user_name/<name>/<age>' (OPTIONS, GET, HEAD, POST) -> user.user_name>
])

Metadata

Release files for flask-controller 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flask-controller 0.0.2
File Size Uploaded Provenance Actions
flask-controller-0.0.2.tar.gz 5.0 kB Without provenance Details for flask-controller-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flask-controller 0.0.2
File Interpreter ABI Platform Actions
flask_controller-0.0.2-py3-none-any.whl Python 3 none any Details for flask_controller-0.0.2-py3-none-any.whl

Total release size: 11.0 kB

Release files / flask-controller-0.0.2.tar.gz

Download URL flask-controller-0.0.2.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
065b804deb02540832d739e6b4e130129893d41aa1c50efd7216718795f2605f
BLAKE2b-256 checksum
How to use checksums
b240f84440b4a71645c5cb59d624dc754661659640e3144db3e5960cc014f3bd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.0

Release files / flask_controller-0.0.2-py3-none-any.whl

Download URL flask_controller-0.0.2-py3-none-any.whl
Size 5.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8f56bee37519abe0eed9c32b41dfdc17b393eda8043db06535b15a6e2aec122c
BLAKE2b-256 checksum
How to use checksums
ebb8b5c93778fa73daac1ede7c3f83ddc2be56c5545f2acbf5ac58c9a2ec482f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.0 pkginfo/1.5.0.1 requests/2.23.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.0 CPython/3.7.0

Security for flask-controller 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page