Metadata-Version: 2.1
Name: suoran
Version: 0.0.3
Summary: extends sanic
Home-page: https://github.com/chenshenchao/suoran
Author: chenshenchao
Author-email: chenshenchao@outlook.com
License: MIT
Keywords: sanic suoran
Platform: any
Classifier: License :: OSI Approved :: MIT License
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Description-Content-Type: text/markdown
Requires-Dist: sanic (>=20.9.0)
Requires-Dist: tortoise-orm (>=0.16.16)
Requires-Dist: aiomysql (>=0.0.20)

# [suoran](https://github.com/chenshenchao/suoran)

## 使用

```bash
pip install suoran
```

### 扩展 Sanic 控制器相关的路由

```python
# app.py
from suoran import Application
from . import controller # 定义控制器的模块或包

app = Application()

@app.listener('before_server_start')
async def initialize(app, loop):
    '''
    初始化。
    '''
    app.control(controller)
```

```python
# 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 })
```

## 源码

### 测试

```bash
# 所有测试
python -m unittest discover test/unit -p *.py

# 指定测试
python -m unittest test.route
```

### 发布

```bash
# 安装发布工具
pip install twine wheel

# 打包
python setup.py sdist bdist_wheel

# 上传
twine upload dist/*
```


