Web Framework |
Environment |
number of Requests/S |
Average Time |
Sanic |
Python 3.5 & Uvloop |
31 |
3ms |
Wheezy |
Gunicorn & Meinheld |
21st |
5ms |
Falcon |
Gunicorn & Meinheld |
19 |
6ms |
Bottle |
Gunicorn & Meinheld |
14 |
7ms |
Flask |
Gunicorn & Meinheld |
5 |
20ms |
Kyoukai |
Python 3.5 & Uvloop |
4 |
27ms |
Aiohttp |
Python 3.5 & Uvloop |
3 |
33ms |
Installation
Environment: python3.5
Run Python3 main.py
Does sanic look like flask?
Request
Routing
And flask Almost, a look at it
Blueprint
Like the blueprints in flask, for organizing project structures
Create a blueprint that is equivalent to creating a Sanic app with the same usage as above and changing the app to a blueprint name BP
Blueprint registration to the main app
From sanic import sanicfrom my_blueprint Import Bpapp = Sanic (__name__) app.register_blueprint (BP) app.run (host= ' 0.0.0.0 ', port=8000, Debug=true)
Summarize
Sanic will be a very popular framework. Because it's based on python3.5, it uses many new features that make the program faster.
Python Web framework for quick Mastery!