talira

Fast asynchronous Python web framework with its own production server

open sourceMITfree

Sanic is an asynchronous Python web framework and web server built for speed, using async/await throughout. It comes with a production-ready server (multiple workers, TLS, automatic local TLS certificates in development), so an app runs with sanic path.to.server:app and no separate server, and it's also ASGI compliant for deployment behind another ASGI server. It has routing, blueprints, middleware, websockets, static files, server lifecycle hooks, signals for built-in and custom events, error handling that answers in HTML, JSON or text, a dev mode error page, and an inspector for running apps. It uses uvloop and ujson when they're available. Sanic needs Python 3.10 or newer and is run by its community.

Problems it solves

  • build a fast async API in Python without a separate web server
  • serve websockets from a Python web app
  • a Python web framework that runs async handlers with its own production server

Features

  • async/await request handlers
  • built-in production web server with workers and TLS
  • automatic local TLS certificates in dev mode
  • ASGI compliant
  • websockets, static files, blueprints and middleware
  • signals for built-in and custom events
  • app inspector for running servers

Alternatives

The same job

These do what Sanic does.

  1. Tornado Python web framework and asynchronous networking library
  2. Starlette Lightweight ASGI framework and toolkit for async Python web services
  3. FastAPI FastAPI framework, high performance, easy to learn, fast to code, ready for production
  4. aiohttp Asynchronous HTTP client/server framework for asyncio and Python
  5. Falcon The minimal, fast, and secure web framework for Python

Compare Sanic with the top 3