Sanic¶
Sanic is a Python 3.6+ web server and web framework that’s written to go fast. It allows the usage of the async/await syntax added in Python 3.5, which makes your code non-blocking and speedy.
The goal of the project is to provide a simple way to get up and running a highly performant HTTP server that is easy to build, to expand, and ultimately to scale.
Sanic is developed on GitHub. Contributions are welcome!
Sanic aspires to be simple¶
from sanic import Sanic
from sanic.response import json
app = Sanic("App Name")
@app.route("/")
async def test(request):
return json({"hello": "world"})
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000)
Note
Sanic does not support Python 3.5 from version 19.6 and forward. However, version 18.12LTS is supported thru December 2020. Official Python support for version 3.5 is set to expire in September 2020.
Guides¶
- Getting Started
- Configuration
- Logging
- Request Data
- Response
- Cookies
- Routing
- Blueprints
- Static Files
- Versioning
- Exceptions
- Middleware And Listeners
- WebSocket
- Handler Decorators
- Streaming
- Class-Based Views
- Custom Protocols
- Sockets
- SSL Example
- Debug Mode
- Testing
- Deploying
- Nginx Deployment
- Extensions
- Examples
- Changelog
- Contributing
- API Reference
- Submodules
- sanic.app module
- sanic.blueprints module
- sanic.blueprint_group module
- sanic.config module
- sanic.constants module
- sanic.cookies module
- sanic.exceptions module
- sanic.handlers module
- sanic.log module
- sanic.request module
- sanic.response module
- sanic.router module
- sanic.server module
- sanic.static module
- sanic.testing module
- sanic.views module
- sanic.websocket module
- sanic.worker module
- Module contents
- Python 3.7 AsyncIO examples