https://github.com/gera2ld/pyserve
Serve asyncio and aiohttp servers
https://github.com/gera2ld/pyserve
Last synced: 18 days ago
JSON representation
Serve asyncio and aiohttp servers
- Host: GitHub
- URL: https://github.com/gera2ld/pyserve
- Owner: gera2ld
- Created: 2018-10-12T15:49:08.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2020-08-04T14:30:13.000Z (almost 6 years ago)
- Last Synced: 2025-01-15T05:52:53.038Z (over 1 year ago)
- Language: Python
- Homepage:
- Size: 17.6 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
README
gera2ld.pyserve
===============
.. image:: https://img.shields.io/pypi/v/gera2ld-pyserve.svg
Serve asyncio and aiohttp servers, and show information for development.
Installation
------------
.. code-block:: sh
$ pip install gera2ld-pyserve
# or with extra `aio` if aiohttp applications are to be served
$ pip install gera2ld-pyserve[aio]
Usage
-----
Run an asynchronous function in an infinite event loop:
.. code-block:: python
from gera2ld.pyserve import run_forever
async def main():
# do stuff
run_forever(main())
Start a server:
.. code-block:: python
from gera2ld.pyserve import run_forever, start_server_asyncio
def handle(reader, writer):
# add more code here...
run_forever(start_server_asyncio(handle, ':4000'))
Start a server with `aiohttp`:
.. code-block:: python
from gera2ld.pyserve import run_forever, start_server_aiohttp
from aiohttp import web
app = web.Application()
# add more code here...
run_forever(start_server_aiohttp(app, ':4000'))