【Sanic】Hello world -- 2019-08-09 10:00:13

原文: http://106.13.73.98/__/221/

       Sanic is based on the asynchronous function async def func() after python3.6, a lot of online introduction, here is not detailed. One thing to note is that Sanic USES uvloop as the asyncio event loop, uvloop is written by Cython and makes asyncio faster, so we'll start with the basics.

pip3 install sanic

Sanic and Flask are similar, such as introducing modules, setting routes and so on.

from sanic import Sanic
from sanic.response import text

app = Sanic()

@app.route('/')
async def index(request):
    return text('Hello world!')

if __name__ == '__main__':
    app.run('0.0.0.0', 8000, True)

原文: http://106.13.73.98/__/221/

猜你喜欢

转载自www.cnblogs.com/gqy02/p/11325331.html