Sanic应用程序实用程序
tails的Python项目详细描述
Sanic(和/或Stellata和/或Webpack)的实用程序集合 应用程序。
cli
假设您有一个名为foo的项目。
运行数据库迁移:
tails foo migrate
建立网页包资产:
tails foo build
运行重新加载服务器+资产更改的调试服务器:
tails foo server --watch --build
运行生产服务器:
tails foo server --production --host=0.0.0.0 --port=9000
一次运行多个项目:
tails ~/foo/foo ~/bar/bar server --port=9001 --port=9002
重置为没有数据的新数据库:
tails foo reset
资源
返回json或html页面:
import foo import tails.resource @foo.app.route('/') async def index(): return tails.resource.html( title='What a great page', external_css=['https://fonts.googleapis.com/icon?family=Material+Icons'], js=['/static/build/js/index.js'], css['/static/build/css/index.css'] ) @foo.app.route('/api') async def api(): data = ... return tails.resource.json({ 'data': data })