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 PyPI PyPI version

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. 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 json 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.

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.

TODO

  • http2

Limitations

  • No wheels for uvloop and httptools on Windows :(

Final Thoughts

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

Project details


Release history Release notifications | RSS feed

This version

0.7.0

Download files

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

Source Distribution

sanic-0.7.0.tar.gz (41.3 kB view details)

Uploaded Source

Built Distribution

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

sanic-0.7.0-py3-none-any.whl (48.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sanic-0.7.0.tar.gz
  • Upload date:
  • Size: 41.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for sanic-0.7.0.tar.gz
Algorithm Hash digest
SHA256 22b1a6f1dc55db8a136335cb0961afa95040ca78aa8c78425a40d91e8618e60e
MD5 aa19bde10f0b025e8e3ba719df3870ff
BLAKE2b-256 c1d4a6fa3efa7aa8ff6fb08cddac6f10e92da95e1fd44d6397fb481bf012c2a0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sanic-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 18a3bd729093ac93a245849c44045c505a11e6d36da5bf231cb986bfb1e3c14c
MD5 8b8a87158930e20570a79e8c160c96f3
BLAKE2b-256 9c9a76fa35936aa51d27f293fc724af62dc7ce84280a6940b50dcb63ba5a7c06

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