suoran
使用
# 安装
pip install suoran
# 创建骨架
suoran new myapp
# 也可以在现有的目录内生成文件
suoran init
扩展 Sanic 控制器相关的路由
# app.py
from suoran import new_application
app = new_application()
@app.listener('before_server_start')
async def initialize(app, loop):
'''
初始化。
'''
# 加载控制器包
app.control('controller')
app.apply()
# controller/__init__.py
from sanic.response import json
from suoran import route
@route.get('/')
async def index(request):
'''
Sanic 类似的定义。
'''
return json({ 'index': 1 })
class IndexController:
'''
'''
@route.get('/index.html')
async def index(self, request):
'''
比 Sanic 多出 self 参数。
'''
return json({ 'index': 2 })
源码
开发
# 安装到本地环境
pip install -e . -i https://pypi.python.org/pypi
# 指定源更新
pip install --upgrade suoran -i https://pypi.python.org/pypi
测试
# 所有测试
python -m unittest discover test/unit -p *.py
# 指定测试
python -m unittest test.route
发布
# 安装发布工具
pip install twine wheel
# 打包
python setup.py sdist bdist_wheel
# 上传
twine upload dist/*
Release files for suoran 0.0.12
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| suoran-0.0.12.tar.gz | 10.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| suoran-0.0.12-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.0 kB
Release files / suoran-0.0.12.tar.gz
| Download URL | suoran-0.0.12.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
264a535787f9125318b2306185cfd97c28c0aaf63a52af93508609bfbf07cecc
|
|
BLAKE2b-256 checksum How to use checksums |
b7428f163adb73ee8e78c18482ff2cbf70b84dbde497735c6f66b47e3efc0f42
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1
|
Release files / suoran-0.0.12-py3-none-any.whl
| Download URL | suoran-0.0.12-py3-none-any.whl |
|---|---|
| Size | 16.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cec74c3daa3e84f3186c83a925aebb4d054f59e392f184537a7dc4b3ff8a23c3
|
|
BLAKE2b-256 checksum How to use checksums |
6cc4e4b4fde0e6677be41a9e909a0e22ac713e91b249ec711bbff578fa6c2f26
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.9.1
|