Skip to main content

xilong router library

Project description

zrouter

基于Flask的路由工具库,集成登录验证、权限控制、日志记录、RESTful API快速构建等功能。

安装

pip install zrouter

基本使用

# 定义路由器
router = Router('body', __name__, url_prefix='/body')


# 添加单一路由
@router.add('/article', methods=['GET'])
def get_article(article_id: int):
    return ArticleMapper.get_json(article_id)

@ router.add('/article', methods=['POST'])
def post_article(article_id: int, data: dict):
    return ArticleMapper.update(article_id, data)


# 添加REST资源
router.add_resource('/metric', MetricResource)


# 批量添加REST资源
router.add_resources({
    '/metric': MetricResource,
    '/sport':  SportResource,
    '/entry': EntryResource,
    '/entry/stat': EntryStatResource,
    '/punch': PunchResource,
    '/punch/stat': PunchStatResource
})

自定义

通过继承实现用户验证方法、错误处理方法。

from zrouter import Router as Router_


class Router(Router_):
    def verify_user(self):
        # 通过继承在此添加代码,实现用户验证、日志记录
    
    def handle_error(self, e):
        # 通过继承在此添加代码,实现错误处理

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

xl_router-0.6.7.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

xl_router-0.6.7-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file xl_router-0.6.7.tar.gz.

File metadata

  • Download URL: xl_router-0.6.7.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.6

File hashes

Hashes for xl_router-0.6.7.tar.gz
Algorithm Hash digest
SHA256 92bde47a39e9dcfbd3561db13ef19eaed648b5724766259e386202be0d105314
MD5 86aad07801cd9c48fefb5273f72b6528
BLAKE2b-256 4f3ae9fa40a280e54f50c6b0f715c31f306b0fc006cb6f889f66cb116aa9cf1c

See more details on using hashes here.

File details

Details for the file xl_router-0.6.7-py3-none-any.whl.

File metadata

  • Download URL: xl_router-0.6.7-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.6

File hashes

Hashes for xl_router-0.6.7-py3-none-any.whl
Algorithm Hash digest
SHA256 fd3f34389eedc4c6007e3cd887bf7f9a2ddd6e703137c090f37bd9825ad4aa6b
MD5 32424c5a7f65834a3f2e573251ccd09e
BLAKE2b-256 aa4b38b43bdc6258ec949245e50600d94a15c81b90fb5f8be85171b971c708a5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page