Skip to main content

Tornado REST framework

https://travis-ci.org/007gzs/tornado-rest-framework.svg?branch=master https://img.shields.io/pypi/v/tornadoapi.svg

Tornado REST framework

【阅读文档】。

安装

目前 tornadoapi 支持的 Python 环境有 2.7, 3.4, 3.5, 3.6 和 pypy。:

pip install tornadoapi

快速开始

启动之前或启动脚本开始时配置环境变量 并执行setup初始化:

os.environ.setdefault("TORNADOAPI_SETTINGS_MODULE", "config.settings")
import tornadoapi
tornadoapi.setup()

config/settings.py 中增加自定义配置:

DEBUG = True
TEST = 1

通过以下代码可以获取到settings参数:

from tornadoapi.conf import settings

settings.TEST

ApiHandler调用示例:

from tornadoapi.handler import ApiHandler

class TestHandler(ApiHandler):
    test_param = fields.CharField(description='测试参数', default=None)
    test_choice = fields.ChoiceField(description='选择参数', default=None, choices=((0, '选项0'), (1, '选项1')))

    @classmethod
    def get_return_sample(cls):
        return ErrCode.SUCCESS.get_res_dict(data={'test_param': '测试参数', 'test_choice' :'选择参数'})

    @classmethod
    def get_handler_name(cls):
        return '测试'

    def get(self, *args, **kwargs):
        ret = {
            'test_param': self.test_param,
            'test_choice': self.test_choice
        }
        self.write_api(ret)

示例项目

demo

Metadata

Release files for tornadoapi 1.1.7

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

Source distribution (sdist)

Source distribution for tornadoapi 1.1.7
File Size Uploaded Provenance Actions
tornadoapi-1.1.7.tar.gz 45.6 kB Without provenance Details for tornadoapi-1.1.7.tar.gz

Release files / tornadoapi-1.1.7.tar.gz

Download URL tornadoapi-1.1.7.tar.gz
Size 45.6 kB
Tags Source
SHA-256 checksum
How to use checksums
eb0b964e6e200d7aa8c8953f670890e8df8b14efaf8d00c7ae15761304529d03
BLAKE2b-256 checksum
How to use checksums
6e2167d861e8f872163c409e633a21a8d3f10b6b9f6cab4593c763f4aab8b2cb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.40.2 CPython/3.7.4

Security for tornadoapi 1.1.7

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.

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