Metadata-Version: 2.1
Name: async-http-minimal
Version: 0.0.4
Summary: Minimalistic async HTTP server
Home-page: https://github.com/denismakogon
Author: Denis Makogon
Author-email: denys.makogon@oracle.com
License: UNKNOWN
Platform: UNKNOWN
Classifier: Intended Audience :: Information Technology
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Requires-Dist: pbr (!=2.1.0,>=2.0.0)
Requires-Dist: httptools (>=0.0.10)

# 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()
```



