Sanic It's a Python 3.7+ web The server and web frame , It's written very fast . It allows the use of async/awaitPython 3.5 Syntax added in , This makes your code non blocking and fast .
sanic github project .
sanic Using document
The goal is :
Provides a simple way to start and run easy to build 、 High performance for expansion and final expansion HTTP The server .
features
Built in fast network server
Production ready
Highly scalable
accord with ASGI
Simple and intuitive API Design
sanic Asynchronous Support ,flask I won't support it
from sanic import Sanic
from sanic.response import json
from sanic.exceptions import NotFound
app = Sanic(name="pyapp")
@app.route('/')
async def test(request):
return json({'hello': 'world'})
if __name__ == '__main__':
app.error_handler.add(
NotFound,
lambda r, e: sanic.response.empty(status=404)
)
app.run(host='0.0.0.0', port=8000)
Access page :
http://localhost:8000/