Skip to main content

A microframework based on uvloop, httptools, and learnings of flask

Project description

Join the chat at https://gitter.im/sanic-python/Lobby Build Status AppVeyor Build Status Documentation 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!  |
   ▀▀█████▄▄ ▀██████▄██ | _________________/
   ▀▄▄▄▄▄  ▀▀█▄▀█════█▀ |/
        ▀▀▀▄  ▀▀███ ▀       ▄▄
     ▄███▀▀██▄████████▄ ▄▀▀▀▀▀▀█▌
   ██▀▄▄▄██▀▄███▀ ▀▀████      ▄██
▄▀▀▀▄██▄▀▀▌████▒▒▒▒▒▒███     ▌▄▄▀
▌    ▐▀████▐███▒▒▒▒▒▐██▌
▀▄▄▄▄▀   ▀▀████▒▒▒▒▄██▀
          ▀▀█████████▀
        ▄▄██▀██████▀█
      ▄██▀     ▀▀▀  █
     ▄█             ▐▌
 ▄▄▄▄█▌              ▀█▄▄▄▄▀▀▄
▌     ▐                ▀▀▄▄▄▀
 ▀▀▄▄▀

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sanic-18.12.0.tar.gz (48.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sanic-18.12.0-py3-none-any.whl (53.0 kB view details)

Uploaded Python 3

File details

Details for the file sanic-18.12.0.tar.gz.

File metadata

  • Download URL: sanic-18.12.0.tar.gz
  • Upload date:
  • Size: 48.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for sanic-18.12.0.tar.gz
Algorithm Hash digest
SHA256 4ce5ffd9588557caff844da0f4b478d263d0e836fa0204480a2a17958b333fe0
MD5 dba18c4d2c615193ebc56cf6ad35b58a
BLAKE2b-256 e1079523ec188557bc534dc1d17f599fd82c19163d1d2e06d607ec9ceae14ec7

See more details on using hashes here.

File details

Details for the file sanic-18.12.0-py3-none-any.whl.

File metadata

  • Download URL: sanic-18.12.0-py3-none-any.whl
  • Upload date:
  • Size: 53.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.21.0 setuptools/40.6.3 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for sanic-18.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e1f291cfc44627baad7e0855512c821fe3dbfe23f7d2a26561abb808d4511f14
MD5 20509ae991c44e538ca9fb874587b3b3
BLAKE2b-256 11b196424ff7d7d53b45adda69ac5306b58f349d1b7a937430aeb397f61452be

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page