Sanic is a Python web framework built on uvloop and designed for fast HTTP responses via asynchronous request handling.
Sanic cannot be developed or deployed on Windows due to its necessary uvloop dependency.
There was
an excellent discussion on the /r/python subreddit
about using one of the newer async frameworks such as Sanic or Japronto
compared with a traditional web framework like
Django. One of the major tradeoff of adopting a newer
framework is simply that the code library ecosystem has not, and may never,
grow up around that framework. You have to accept the risk that you will
need to build a significant amount of the plumbing yourself rather than
pip
installing existing, well-tested libraries.
Sanic is under very active development and is still in its infancy as a web framework. The following tutorials will get you started but there is a chance you will have to work through errors as Sanic is regularly updated.
Getting started with Sanic: the asynchronous, uvloop based web framework for Python 3.5+ is a "Hello, World!" style post for the framework and also shows how to respond to SMS text messages using Twilio.
Fixing bugs and handling 186k requests/second using Python is a fun benchmarking exercise that a developer ran when testing out Sanic on a Digital Ocean droplet.
Exploring Asyncio - uvloop, sanic and motor explains why asyncio is important to the Python community and how uvloop & sanic fit into the bigger picture.
Python Sanic Tutorial is a video tutorial on how to write your first Sanic web apps.
A Guide to Instrumenting Sanic Applications, Part 1 shows how to add Prometheus-based monitoring to Sanic applications.
There are not many example applications and extensions for Sanic compared to Flask, Django or other web frameworks because Sanic is still so new. However, there are some initial projects that are useful for figuring out how to build your first applications with this framework.
Gutenberg-HTTP is a web application and API built with Sanic. It's a solid clean example of how to build a decent-sized project with Sanic. There is even a demo that was deployed to Azure to show how it works.
Practical Log Viewers with Sanic and Elasticsearch - Designing CI/CD Systems shows how to build a log viewer using Sanic that collects data from various Docker containers being created through a build system.
Sanic comes with a slew of examples in the official repository.
Sanic starter bundles Sanic with SQLAlchemy and Alembic (for data migrations) as a starter project.
Sanic-limiter is an extension for rate-limiting the number of requests from a single user on Sanic APIs.
Sanic-GraphQL adds GraphQL support to a Sanic web application.
Sanic OpenAPI provides a user interface for Sanic APIs.
This Sanic & Nginx & docker-compose example has boilerplate code for setting up a Sanic project using Docker and Nginx.
Sanic JWT (source code) adds support for authentication via JSON Web Tokens (JWT).