aiohttp-runner-0.5.0
توضیحات
Wraps aiohttp or gunicorn server for aiohttp application.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | aiohttp-runner-0.5.0 |
| نام | aiohttp-runner |
| نسخه کتابخانه | 0.5.0 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | xppt |
| ایمیل نویسنده | 21246102+xppt@users.noreply.github.com |
| آدرس صفحه اصلی | - |
| آدرس اینترنتی | https://pypi.org/project/aiohttp-runner/ |
| مجوز | - |
Install
---
```
pip install aiohttp-runner
```
Example usage
---
```python
import asyncio
import aiohttp.web
from async_generator import asynccontextmanager
from aiohttp_runner import (
simple_http_runner, gunicorn_http_runner,
HttpRequest, HttpResponse,
create_http_app, wait_for_interrupt,
)
@asynccontextmanager
async def app_factory():
yield create_http_app(routes=[
('GET', '/', http_handler),
])
async def http_handler(_req: HttpRequest) -> HttpResponse:
return aiohttp.web.Response(status=204)
async def main() -> None:
bind = '127.0.0.1:8080'
runner = gunicorn_http_runner(app_factory, bind, workers=2)
# OR
runner = simple_http_runner(app_factory, bind)
async with runner:
await wait_for_interrupt()
if __name__ == '__main__':
asyncio.get_event_loop().run_until_complete(main())
```
نیازمندی
| مقدار | نام |
|---|---|
| >=3,<4 | aiohttp |
| >=1,<2 | async-exit-stack |
| >=1,<2 | async_generator |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.6,<4.0 | Python |
نحوه نصب
نصب پکیج whl aiohttp-runner-0.5.0:
pip install aiohttp-runner-0.5.0.whl
نصب پکیج tar.gz aiohttp-runner-0.5.0:
pip install aiohttp-runner-0.5.0.tar.gz