Python的web框架sanic

来源:互联网 发布:spring软件怎么下 编辑:程序博客网 时间:2024/06/06 13:07

Python 3.5+ web server that’s written to go fast

前段时间发现了一个新的Python web框架,看到Benchmarks有点心动,决定上手实验一波

这里写图片描述

from sanic import Sanicfrom sanic.response import htmlfrom jinja2 import Environment, PackageLoaderenv = Environment(loader=PackageLoader('app', 'templates'))app = Sanic(__name__)@app.route('/')async def test(request):    data = {'name': 'Hello world!'}    template = env.get_template('index.html')    html_content = template.render(name=data["name"])    return html(html_content)app.run(host="127.0.0.1", port=8000)

文件目录


这里写图片描述

这里写图片描述

0 0