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

  • python -m 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 python -m 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.6.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.6.0.tar.gz (38.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-0.6.0-py3-none-any.whl (46.7 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for sanic-0.6.0.tar.gz
Algorithm Hash digest
SHA256 f70fbd2483e372494d023a08259ffbeb757b3bce10bbf4a00b17a405de3ff322
MD5 4fce620187338405bb84a3de109b57b9
BLAKE2b-256 d53865c654c8c412984fc78a9460cf9add5cbd3a6ee87788160eecaa1ec90529

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sanic-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6c5d0d049335975936f74b3a62e5443cb0af5618f32b1a4de5976d2c5bcdc823
MD5 ee7717fe66442f6b6d059d72d65b5c4f
BLAKE2b-256 a86d61051883ae6ed657b34fddacae8d5fc391cee86f57b93efc4c7b08a270d4

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