Skip to main content

Minimalistic async HTTP server

Project description

# Minimalistic async HTTP server

This framework was inspired by [sanic](https://github.com/huge-success/sanic) framework.
This framework designed to be fast and be capable to start within 1.5 seconds at max (see [cold start problem](https://medium.com/@denismakogon/investigating-pythons-performance-issue-cold-start-8ebf443a8a20)).

## How to install

```bash
pip install async-http-minimal
```

## Example

```python
import asyncio
import socket

from async_http import app
from async_http import router
from async_http import response

async def hello(request):
return response.text("hello-world!")


if __name__ == "__main__":
loop = asyncio.get_event_loop()
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.bind(("localhost", 9999))

rtr = router.Router()
rtr.add("/hello", frozenset({"GET"}), hello)
srv = app.AsyncHTTPServer(name="hello-world-server", router=rtr)
start_serving, run_forever = srv.run(sock=sock, loop=loop)

start_serving()
# here you can do some additional operations before starting an infinite serving
# can be helpful for unix sockets, etc.
run_forever()
```



Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

async_http_minimal-0.0.2-py3-none-any.whl (35.3 kB view details)

Uploaded Python 3

File details

Details for the file async_http_minimal-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: async_http_minimal-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 35.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.5.0.1 requests/2.21.0 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.29.0 CPython/3.7.1

File hashes

Hashes for async_http_minimal-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 71c4f82b7ec440e23db5ee82b6139a5134ed4d495cf536bb5fa270e86eb3bf10
MD5 8bcc83f240f602637dc2d3b940396e48
BLAKE2b-256 02f69668bf0257bdbcde834dc11ab9f8b944dccf41aecb4311691b2ba9013fc5

See more details on using hashes here.

Supported by

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