Giter Site home page Giter Site logo

suoran's Introduction

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/*

suoran's People

Contributors

chenshenchao avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.