A Rust HTTP server for Python applications
Project description
Granian
A Rust HTTP server for Python applications.
Rationale
The main reasons behind Granian design are:
- Have a single, correct HTTP implementation, supporting versions 1, 2 (and eventually 3)
- Provide a single package for several platforms
- Avoid the usual Gunicorn + uvicorn + http-tools dependency composition on unix systems
- Provide stable performance when compared to existing alternatives
Features
- Supports ASGI/3, RSGI and WSGI interface applications
- Implements HTTP/1 and HTTP/2 protocols
- Supports HTTPS
- Supports Websockets over HTTP/1 and HTTP/2
Quickstart
You can install Granian using pip:
$ pip install granian
Create an ASGI application in your main.py
:
async def app(scope, receive, send):
assert scope['type'] == 'http'
await send({
'type': 'http.response.start',
'status': 200,
'headers': [
[b'content-type', b'text/plain'],
],
})
await send({
'type': 'http.response.body',
'body': b'Hello, world!',
})
and serve it:
$ granian --interface asgi main:app
You can also create an app using the RSGI specification:
async def app(scope, proto):
assert scope.proto == 'http'
proto.response_str(
status=200,
headers=[
('content-type', 'text/plain')
],
body="Hello, world!"
)
and serve it using:
$ granian --interface rsgi main:app
Options
You can check all the options provided by Granian with the --help
command:
$ granian --help
Usage: granian [OPTIONS] APP
Arguments:
APP Application target to serve. [required]
Options:
--host TEXT Host address to bind to. [default:
127.0.0.1]
--port INTEGER Port to bind to. [default: 8000]
--interface [asgi|rsgi|wsgi] Application interface type. [default: rsgi]
--http [auto|1|2] HTTP version. [default: auto]
--ws / --no-ws Enable websockets handling [default:
(enabled)]
--workers INTEGER RANGE Number of worker processes. [default: 1;
x>=1]
--threads INTEGER RANGE Number of threads. [default: 1; x>=1]
--threading-mode [runtime|workers]
Threading mode to use. [default: workers]
--loop [auto|asyncio|uvloop] Event loop implementation [default: auto]
--backlog INTEGER RANGE Maximum number of connections to hold in
backlog. [default: 1024; x>=128]
--log-level [critical|error|warning|warn|info|debug]
Log level [default: info]
--log-config FILE Logging configuration file (json)
--ssl-keyfile FILE SSL key file
--ssl-certificate FILE SSL certificate file
--url-path-prefix TEXT URL path prefix the app is mounted on
--reload / --no-reload Enable auto reload on application's files
changes [default: no-reload]
--version Shows the version and exit.
--install-completion [bash|zsh|fish|powershell|pwsh]
Install completion for the specified shell.
--show-completion [bash|zsh|fish|powershell|pwsh]
Show completion for the specified shell, to
copy it or customize the installation.
--help Show this message and exit.
Project status
Granian is currently under active development.
Granian is compatible with Python 3.8 and above versions.
License
Granian is released under the BSD License.
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
granian-0.4.3.tar.gz
(52.2 kB
view hashes)
Built Distributions
Close
Hashes for granian-0.4.3-pp39-pypy39_pp73-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c0cdabaa22d1712e2ba1bdfce1f385b3df535209c3ca8cef8faa6811c98fd9d2 |
|
MD5 | d7bc6af23398ea98474a1637d35cc66a |
|
BLAKE2b-256 | f0ea310e5632993ad5b5b5990872d9a60f21c61ca49c38cc53925c0b9c3420d3 |
Close
Hashes for granian-0.4.3-pp39-pypy39_pp73-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4c120d4fceff8598030482c0ec6b29e8bfebdaf3b00a8b4e34eec41259be583 |
|
MD5 | 5ad327ddfd9dccc03a6afaa163922643 |
|
BLAKE2b-256 | 152d648592608891cc7a9b8e02f97336ff88767e4150c88bc5d0adab95467978 |
Close
Hashes for granian-0.4.3-pp39-pypy39_pp73-musllinux_1_1_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b96c58f88697d9836aa4ea45eb45a4fd5f063410205e3da3ebfa54fbdef44bdf |
|
MD5 | 99fff83d2adae6d1b29adfe378e5ed65 |
|
BLAKE2b-256 | 191462c6a50225b63747576a774745c00ae8777b1b43251643ded3f0db1c45fb |
Close
Hashes for granian-0.4.3-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 690fbc1acfb10cbc4a90a788c530263c52d54196eaf373a338d8a4c947eb51b9 |
|
MD5 | a328c55e68a25cf496d75f6473db60b2 |
|
BLAKE2b-256 | 8ce8c7bed7f471597c97fb740fcb6da37c8a9ec818dc5582b36722cfcf3bf721 |
Close
Hashes for granian-0.4.3-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3a121791318d9a1b513b94a2f92d0b892b6779ac244fa8dbfe9756275e49ebb |
|
MD5 | cae9e90c22f47bd53a670553c160eb0f |
|
BLAKE2b-256 | 2d483a0f8c0457f37263c8ecefc1f81c68f3c1b087da24b1aa6c7f2ec3d24a32 |
Close
Hashes for granian-0.4.3-pp39-pypy39_pp73-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bec40556f6ba4d27792dad7ecd30e14109bf309f73f20e9a893770e920b5fce5 |
|
MD5 | 5dade872a5382f20218aa0993f516ae8 |
|
BLAKE2b-256 | de74269984063817fceb4398c74b9ef47dc5865b9b3416787276a0f022d293e1 |
Close
Hashes for granian-0.4.3-pp39-pypy39_pp73-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72773400a43a936eb8503d04d57c1f5044309e387bbe68d53f635a8ac5c42e33 |
|
MD5 | 2250571b1cb559051fc4b25518758f6d |
|
BLAKE2b-256 | 320cf977b9d16c2c0b537c7f6364c57704d78271c9213e84976696711a073575 |
Close
Hashes for granian-0.4.3-pp38-pypy38_pp73-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | af6ff496e698b080b393ced0c0bf5af699540dd79664f2189910b41808819762 |
|
MD5 | 865a3b78386a3aa15fb048e72c6c69be |
|
BLAKE2b-256 | 7fbc6d62cde0019d15e292d6e2b0b65b384be24eeacab3296363ec3a1fc5b9ff |
Close
Hashes for granian-0.4.3-pp38-pypy38_pp73-musllinux_1_1_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d958f1824bd104ffb7e9e30eeabf107961545e333966c1caf049659eedd74d2c |
|
MD5 | c0cba8e19493abf1c9be245c944d4d04 |
|
BLAKE2b-256 | 86c84c811592ac776a14edeb92ded2d782ed7d94dffab8e2d2c0b47ae53aa203 |
Close
Hashes for granian-0.4.3-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df0e2d5b43cc5723dc8823230dcdf480a93f7203aea1ca4c92161f9e6beedb8e |
|
MD5 | 105da5ba58dfa7a4c51226fbe5e3b301 |
|
BLAKE2b-256 | 71dc07b4c9d05efaf9438a239726be62649a8e5f0ae2d985b081a67833ea1458 |
Close
Hashes for granian-0.4.3-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89c261b989a7cf471fcb23e4f5501d3b9e192d19838d95a481e097462669de6e |
|
MD5 | ce3d158d39be663281991fbce1fe6b43 |
|
BLAKE2b-256 | d24caccbfc2030c20143f178b94a79aafb749ea94084bcd7f55b336276f47ff6 |
Close
Hashes for granian-0.4.3-cp311-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8090c23d8cdbb5112a5ef94fe2138dfaaa1e53caf2cc22cb1e50e78cdef495b3 |
|
MD5 | 4aae0a65d1e42ca1a4ec7b390b6b8571 |
|
BLAKE2b-256 | de13ff296bfd2f31d1cbdd4a3950534d7de91c1644492b4076816bd95759fe88 |
Close
Hashes for granian-0.4.3-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c25062a32330c5d30a7f056b0ff1990b07bfe2754edbd32fe4ed075c36f35097 |
|
MD5 | dcb638430f2e786be9567ec6a9b533c3 |
|
BLAKE2b-256 | 1b10af75b35aa9a5e3fac6dacef8e484a89b339d5f3d42d511179d8d532427de |
Close
Hashes for granian-0.4.3-cp311-cp311-musllinux_1_1_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a8e8c61173c9641344e5b96f507711dc880bee35375d9df13bd15af5806ebde |
|
MD5 | a74f7fa94e35d9b2b57eeff4c951c9a3 |
|
BLAKE2b-256 | 56b34a0c13d750f5535e2596e68f3bfff7d50850624ba05dd50499bf61da43c9 |
Close
Hashes for granian-0.4.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7204d3180a4f098ac5ec07524fdd17059bc45a49d904773a215a0c4f53fcb686 |
|
MD5 | 0454f52dfa467989d035d5edcd27cf16 |
|
BLAKE2b-256 | 8cdc22b07474c18d25639fe5efef0f9d1cd9c3248883f1448f31d380d25c4093 |
Close
Hashes for granian-0.4.3-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae4a1897187c8cf4c1441c843c83b10999fa7b2af72614fabe7a5c0ef8433c5b |
|
MD5 | 79511ffb05bd18c2fbda52203d8f4c61 |
|
BLAKE2b-256 | 4917c181689913066796daac2845e14d5059464522eacec8023a35d3d6ad7667 |
Close
Hashes for granian-0.4.3-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8727bd888bf2bc99f4ae4ccd2715afcfa3b69bd509335ff8746c87c22764c480 |
|
MD5 | 1d4d4cbb1143f6c351290359d38ef667 |
|
BLAKE2b-256 | 2167dd0e14fd9853300b84e25b959366930a25b3949fd4fb46771c20d8c1b699 |
Close
Hashes for granian-0.4.3-cp311-cp311-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df5f9217a55df0c33edb5d6a7a8b486bcdd32e84015693db24121d585e429526 |
|
MD5 | 3a9b8041a4403f1aa9084d8528a61423 |
|
BLAKE2b-256 | 5c7b04b341f826dcc16c55f22324a6506a69a7d31e04713ce0af712eba3941f8 |
Close
Hashes for granian-0.4.3-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45cddd927caa311428536076cbd9cc96d1d2d47e7dadaea3fa6fb7bc2c53709a |
|
MD5 | 9c8b0edfb52bbedf075378320aee257f |
|
BLAKE2b-256 | 28ea674d1351911085dd0ab9a7279feeafd9c1be98026a0ddf9e756155dc49d1 |
Close
Hashes for granian-0.4.3-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3cd1c3ca6f68d476c6b504f502b9f9fc04b4d63a1a054607bf0365ab60890376 |
|
MD5 | 33540e374ce90b09cb44feb35710951b |
|
BLAKE2b-256 | 4a66a4993903d18a681ab415734334cbeb3abf19be99d9e59135c498d4401536 |
Close
Hashes for granian-0.4.3-cp310-cp310-musllinux_1_1_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 482cfdab5e0a529044ae5b9fbb49ab4f6393adafa6cd11896edc0342333b93dc |
|
MD5 | 47209049b66eb43a8bb79785123a37e7 |
|
BLAKE2b-256 | 4cd7e16bd4bb4e2c83961d0d2e3dae39e6847674cb066f184b1b59da21c9a5e7 |
Close
Hashes for granian-0.4.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7baa9ed2fdd94d59b497c1eed2609ac584b1dfba90a68a5cb9ca62d8514b61b |
|
MD5 | 5a1cc3d2a8ec14ac9ba9a59c7e9466ae |
|
BLAKE2b-256 | 1ca849560956e3148a99a00b95071dac42de26a1e49fb5d9530f7de4dd6ef7ec |
Close
Hashes for granian-0.4.3-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90eb450e174c89f929ca435e12fd06268acad744e7bff41df78054a2e3befb6d |
|
MD5 | 879adcf423ae16645e656eddf6bb4ce9 |
|
BLAKE2b-256 | 2609dc2a48707f4ccb98597c0b6f79c287801a23264dd15b8aa84cff6ffa2273 |
Close
Hashes for granian-0.4.3-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0538ba650431c33f12d2ee2e0a7618b492307d4f4c8271cacc55a908dd328a8b |
|
MD5 | 922b4d9b7a59003fff709c225a90a70b |
|
BLAKE2b-256 | 5055483a158d398470b2ec28aedc1054c92a9d475690a09b2fd43caedbd534db |
Close
Hashes for granian-0.4.3-cp310-cp310-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2360d0cd8624ec7c017c80086a2b77dd94db4cd5b5bb099bacfd4f8fb7711e8e |
|
MD5 | cdd9c877dc632d9d714d92b574f30487 |
|
BLAKE2b-256 | f048e7677c3cf69c971d27dec1cbb7a7e15c7acc72fc8ad59dcf8a5481d91f24 |
Close
Hashes for granian-0.4.3-cp39-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8787a507a85e74797ab73db604ba7c7df9d0671e0d21d8857d86d9e19382414a |
|
MD5 | a63f2ed1f8150b7970c173ad48697c5f |
|
BLAKE2b-256 | bece26f9a171bc19697b8cbf05cf1835592a2f1b5aec47b1644356db62685fbb |
Close
Hashes for granian-0.4.3-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e33802614dc28a1f92f8c4195da92f03f69d2017498f15439064a766a35e563 |
|
MD5 | 6342f9f3c638d5a8c05221ab8690436c |
|
BLAKE2b-256 | c79acf93657ffae8ed989335c3cc73e6a6d3607909be58307672b58f57ef2872 |
Close
Hashes for granian-0.4.3-cp39-cp39-musllinux_1_1_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 30917236c76c5c61f6fb2de755f4828afd2191f8d7e25e41c5fe83fd86789107 |
|
MD5 | 50fd2b1aa037635e960a0aaf3fda67d7 |
|
BLAKE2b-256 | 75b780228985dba301b363ea6e667190b3dcd6499774ff2cbf639d191e5f647f |
Close
Hashes for granian-0.4.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b53f76e073d25683b2e6d5872041f48a36278824442a2f514daf526060d01f1 |
|
MD5 | a5e5e14b34ca29c517a755b60fd151d4 |
|
BLAKE2b-256 | 67ff43f8a820937301bfc4c6d01befd0447698519cd584a7f26155e68b0223d3 |
Close
Hashes for granian-0.4.3-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8e242187d843906cd540fc40e962ad9b5771480e5f1c99d0488fe4091887bf1 |
|
MD5 | 65b624f6dfc217deb9e7c41b97a2fb81 |
|
BLAKE2b-256 | c0cdac3f921a9ced652cac3aa0d9fb573537fef042028f1a51cfb253fd99e19e |
Close
Hashes for granian-0.4.3-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55a0be3f4abf17dd6bff71f3779885eec551ef78d938dba9e9a51015dd44534f |
|
MD5 | cb7fea1b6d5da5d1acde7ddd5b7d444e |
|
BLAKE2b-256 | 9a4db46be931b2f3871d578766e02cd08a1e350320e3dd3eab282f231ef4c304 |
Close
Hashes for granian-0.4.3-cp39-cp39-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 153477f02b9a7ad2045e94b0201fc3baeb686f1e4dc676df634242c159630c57 |
|
MD5 | 6cc954794bf3d2169302c2e90c02395d |
|
BLAKE2b-256 | 4fd047379d7ba09ccf913b6d2c5f6141dada2a8909888edf3d012f6d4e416be3 |
Close
Hashes for granian-0.4.3-cp38-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8df11c31f24c79653297a42d812e2eb7783f7520517e3032e25d1da3e7272205 |
|
MD5 | 002bcdb50ae6e0f98e8ab01e602c22a3 |
|
BLAKE2b-256 | b928541c22533d636e2d71d773d4180e0989573699bd8ba2542678e20f0a2731 |
Close
Hashes for granian-0.4.3-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f7a33ce387f6ea93da396a012a64091bbd9b0e1124cefdd26c5b1d2ab234ac22 |
|
MD5 | 7728f05ad2a0490b47fb7ab115737d16 |
|
BLAKE2b-256 | db47abc2126e4c3b6d73d4a32d3dea10043b9ccf24dcff71d2e81d2e2f15a2f8 |
Close
Hashes for granian-0.4.3-cp38-cp38-musllinux_1_1_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72721d90c72a4bc17197122b601e5eb5247f2e884e5b2bfa8f5e60d4f9cd3ed0 |
|
MD5 | d6146370578a967646ffb4cbeac93cc7 |
|
BLAKE2b-256 | 3765b7d2af0a56e68108a7181ec6cf212fd210b6dc0aa329167c087c3faadc77 |
Close
Hashes for granian-0.4.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36b659f57b1104b284da648e228446ec72232ef21f07909d3a982097f2093bc6 |
|
MD5 | bfaef61b660631cc1c3d9fc2bac1d944 |
|
BLAKE2b-256 | 83793df40e97c583bcfad252cd31e4f65633c3da48a5214628742ee09d5d1aad |
Close
Hashes for granian-0.4.3-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df15a2ba75ca8d22374c7b3544efa744c0bd0c88ca537fe61cc3695a18f6ae15 |
|
MD5 | cab162b9d92e77fbe069b734047d4047 |
|
BLAKE2b-256 | f60de278bfb9ed19721b92a139625151f7c20715b08573a70282263e7d3e904e |
Close
Hashes for granian-0.4.3-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8408ae7cf535e059b4b7e8ff64b3f8926b6a48baedd925018090c1a74a30cd0d |
|
MD5 | 9c167b668bf106c5780c40149eeb73bb |
|
BLAKE2b-256 | c74bb0b87743bb63a86cf0eb7f104e357d1ce8246364b7236f641a26f1956149 |
Close
Hashes for granian-0.4.3-cp38-cp38-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 90de71f24e9c3dcada52664f915e5d76e785bd9dd2cdf9725370521d3b09e769 |
|
MD5 | 2418379d55daa79097e36838b5b670b8 |
|
BLAKE2b-256 | 47cfda058b2389d0059b689313f220c09890ecba0ebcb8e37c54b7edbf3a6a46 |