Skip to content
Async Python 3.6+ web server/framework | Build fast. Run fast.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github add help wanted in stale.yml May 22, 2019
docker Install Python 3.5 and 3.6 on docker container Jan 24, 2018
docs Updated routing docs (#1620) Jul 4, 2019
examples Add placement of before_server_start and after_server_stop Jun 4, 2019
sanic 19.6.2 release Jul 7, 2019
tests Merge pull request #1614 from huge-success/asgi-custom-request Jul 6, 2019
.appveyor.yml Create requests-async based TestClient, remove aiohttp dependency, dr… Apr 30, 2019
.black.toml Create requests-async based TestClient, remove aiohttp dependency, dr… Apr 30, 2019
.coveragerc Increase testing coverage for ASGI Jun 18, 2019
.gitattributes Introduce end-of-line normalization Oct 15, 2016
.gitignore Fix #1528 (#1549) Apr 12, 2019
.travis.yml Add bandit code static analyzer for security, some false positives re… Jun 24, 2019
CHANGELOG.md release: add 19.6.0 standard release changelog Jun 21, 2019
CONDUCT.md Add maintainers email address May 22, 2017
CONTRIBUTING.md developer guide enhancements. May 8, 2019
LICENSE Create requests-async based TestClient, remove aiohttp dependency, dr… Apr 30, 2019
MANIFEST.in add code beautification task to makefile Dec 28, 2018
Makefile Create requests-async based TestClient, remove aiohttp dependency, dr… Apr 30, 2019
README.rst doc: GIT-1582: add fedora package dependency May 22, 2019
SECURITY.md Create SECURITY.md May 23, 2019
environment.yml bump request-async version for fixing build time issue May 16, 2019
readthedocs.yml Adding readthedocs file Jan 30, 2017
release.py make release script black compliant and tweak documentation with inde… Dec 28, 2018
setup.cfg Create requests-async based TestClient, remove aiohttp dependency, dr… Apr 30, 2019
setup.py Add bandit code static analyzer for security, some false positives re… Jun 24, 2019
tox.ini Add custom request support to ASGI mode; fix a couple tests Jun 24, 2019

README.rst

Sanic | Build fast. Run fast.

Sanic | Build fast. Run fast.

Build
Docs Documentation
Package
Support
Stats

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.

Source code on GitHub | Help and discussion board.

The project is maintained by the community, for the community. Contributions are welcome!

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.

Installation

pip3 install sanic

Sanic makes use of uvloop and ujson to help with performance. If you do not want to use those packages, simply add an environmental variable SANIC_NO_UVLOOP=true or SANIC_NO_UJSON=true at install time.

$ export SANIC_NO_UVLOOP=true
$ export SANIC_NO_UJSON=true
$ pip3 install --no-binary :all: sanic

Note

If you are running on a clean install of Fedora 28 or above, please make sure you have the redhat-rpm-config package installed in case if you want to use sanic with ujson dependency.

Hello World Example

from sanic import Sanic
from sanic.response import json

app = Sanic()

@app.route('/')
async def test(request):
    return json({'hello': 'world'})

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=8000)

Sanic can now be easily run using python3 hello.py.

[2018-12-30 11:37:41 +0200] [13564] [INFO] Goin' Fast @ http://0.0.0.0:8000
[2018-12-30 11:37:41 +0200] [13564] [INFO] Starting worker [13564]

And, we can verify it is working: curl localhost:8000 -i

HTTP/1.1 200 OK
Connection: keep-alive
Keep-Alive: 5
Content-Length: 17
Content-Type: application/json

{"hello":"world"}

Now, let's go build something fast!

Documentation

Documentation on Readthedocs.

Changelog

Release Changelogs.

Questions and Discussion

Ask a question or join the conversation.

Contribution

We are always happy to have new contributions. We have marked issues good for anyone looking to get started, and welcome questions on the forums. Please take a look at our Contribution guidelines.

You can’t perform that action at this time.