Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/hzlmn/sketch

Tiny aiohttp clone, made for learning purposes
https://github.com/hzlmn/sketch

aiohttp asyncio

Last synced: 11 days ago
JSON representation

Tiny aiohttp clone, made for learning purposes

Lists

README

        


Sketch


Super tiny aiohttp clone, made for DIY Async Web Framework guide


Code style: black

### Features :sparkles:
- Application container
- Lifecycle hooks
- Middlewares
- Routing
- Request/Response helpers

### Overview

To give you a first grasp, here is simple example of app made with `sketch`

`app.py`
```python3
import asyncio

from sketch import Application, Response, run_app

loop = asyncio.get_event_loop()

async def handler(request):
username = request.match_info["username"]
return Response(f"Hello, {username}")

app = Application(loop)

app.router.add_route("GET", "/{username}", handler)

if __name__ == "__main__":
run_app(app, port=8080)

```

```shell
$ python app.py
>> Started server on 127.0.0.1:8080
```

```shell
$ curl http://127.0.0.1:8080/oleh
>> Hello, oleh
```

### License
MIT