Building Asynchronized HTTP Services With Sanic
Python introduced async/await syntax from Python3.5. it makes your code non-blocking and speedy. Developers can use it to build a high-performance / NIO web services like NodeJS. Most of the Python web developers are familiar with Flask. But unfortunately flask has no plan to support the async request headers. Sanic is a Flask-like webserver that’s written to go fast. It was inspired by uvloop.
I set up a sanic boilerplate to show how to set up a sanic application. Inside of this project:
Dockerfile
anddocker-compose.yml
are used to set up the python environmentsgunicorn
is the application serverBlueprint
is used to build different parts of the applications (health-check / docs / business logic samples)- Eventloop is based on
asyncio
anduvloop