Async Python 3.5+ web server that's written to go fast
Clone or download
sjsadowski Merge pull request #1375 from sjsadowski/master
Added documentation for AF_INET6 and AF_UNIX socket usage
Latest commit 5ead679 Oct 22, 2018
Permalink
Failed to load latest commit information.
.github/ISSUE_TEMPLATE Update issue templates Oct 16, 2018
docker Install Python 3.5 and 3.6 on docker container Jan 24, 2018
docs Added documentation for AF_INET6 and AF_UNIX socket usage Oct 19, 2018
examples Pausable response streams (#1179) Aug 19, 2018
sanic run black against sanic module Oct 14, 2018
tests Fix some lint errors and warnings in `tests/test_blueprints.py`. Oct 14, 2018
.coveragerc Fix response ci header (#1244) Jul 11, 2018
.gitattributes Introduce end-of-line normalization Oct 15, 2016
.gitignore fixed small doc issue (#877) Aug 2, 2017
.travis.yml fix travisci Oct 14, 2018
CHANGELOG.md Corrected Raphael Deem's name in changelog - sorry @r0fls! Sep 24, 2018
CONDUCT.md Add maintainers email address May 22, 2017
CONTRIBUTING.md Add Code of Conduct May 19, 2017
LICENSE Fix LICENSE date and name Aug 30, 2017
MANIFEST.in include LICENSE file in manifest Oct 17, 2017
Makefile Install Python 3.5 and 3.6 on docker container Jan 24, 2018
README.rst add codestyle badge in README Oct 14, 2018
environment.yml Merge pull request #1304 from ignatenkobrain/fedora Oct 4, 2018
pyproject.toml run black against sanic module Oct 14, 2018
readthedocs.yml Adding readthedocs file Jan 30, 2017
requirements-dev.txt pinned httptools requirement to version 0.0.10+ Oct 3, 2018
requirements-docs.txt add sphinx extension to add asyncio-specific markups Sep 29, 2017
requirements.txt Merge pull request #1304 from ignatenkobrain/fedora Oct 4, 2018
setup.cfg added black for lint check Oct 14, 2018
setup.py added black for lint check Oct 14, 2018
tox.ini added black for lint check Oct 14, 2018

README.rst

Sanic

Join the chat at https://gitter.im/sanic-python/Lobby Build Status Codecov PyPI PyPI version Code style black

Sanic is a Flask-like Python 3.5+ web server that's written to go fast. It's based on the work done by the amazing folks at magicstack, and was inspired by this article.

On top of being Flask-like, Sanic supports async request handlers. This means you can use the new shiny async/await syntax from Python 3.5, making your code non-blocking and speedy.

Sanic is developed on GitHub. We also have a community discussion board. Contributions are welcome!

If you have a project that utilizes Sanic make sure to comment on the issue that we use to track those projects!

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)

Installation

  • pip install sanic

To install sanic without uvloop or ujson using bash, you can provide either or both of these environmental variables using any truthy string like 'y', 'yes', 't', 'true', 'on', '1' and setting the NO_X to true will stop that features installation.

  • SANIC_NO_UVLOOP=true SANIC_NO_UJSON=true pip install sanic

Documentation

Documentation on Readthedocs.

Questions and Discussion

Ask a question or join the conversation.

Examples

Non-Core examples. Examples of plugins and Sanic that are outside the scope of Sanic core.

Extensions. Sanic extensions created by the community.

Projects. Sanic in production use.

Final Thoughts

                 ▄▄▄▄▄
        ▀▀▀██████▄▄▄       _______________
      ▄▄▄▄▄  █████████▄  /                 \
     ▀▀▀▀█████▌ ▀▐▄ ▀▐█ |   Gotta go fast!  |
   ▀▀█████▄▄ ▀██████▄██ | _________________/
   ▀▄▄▄▄▄  ▀▀█▄▀█════█▀ |/
        ▀▀▀▄  ▀▀███ ▀       ▄▄
     ▄███▀▀██▄████████▄ ▄▀▀▀▀▀▀█▌
   ██▀▄▄▄██▀▄███▀ ▀▀████      ▄██
▄▀▀▀▄██▄▀▀▌████▒▒▒▒▒▒███     ▌▄▄▀
▌    ▐▀████▐███▒▒▒▒▒▐██▌
▀▄▄▄▄▀   ▀▀████▒▒▒▒▄██▀
          ▀▀█████████▀
        ▄▄██▀██████▀█
      ▄██▀     ▀▀▀  █
     ▄█             ▐▌
 ▄▄▄▄█▌              ▀█▄▄▄▄▀▀▄
▌     ▐                ▀▀▄▄▄▀
 ▀▀▄▄▀