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
    })

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java使用Eclipse Helios for Web项目   java指定行。作为编译器设置的分隔符?   osm映射中带有osmdroid的java标记   java Android ClassNotFoundException在路径:DexPathList上未找到类   java从j2me调用GWT方法   更新到java 8后的aspectj问题   如何仅从根元素java,com提取文本内容。滴虫软件。是的。html   安卓公司。谷歌。火基。数据库DatabaseException:未能转换java类型的值。将字符串改为长字符串   从java中的方法返回arraylist变量   java如果将引用重新分配给同步块内的锁对象,会是什么?   java下载。使用spring mvc的资源文件中的xlsx文件   java Eclipse提供了什么工具来运行Eclipse中未包含的程序?   spring boot Java泛型如何读取传递给泛型方法的类型上的字段或调用方法   Javacard中的javaecdsa签名