Metadata-Version: 2.4
Name: gera2ld-pyserve
Version: 0.3.2
Summary: Start serving an asyncio.Server
License: MIT
Author: Gerald
Author-email: gera2ld@163.com
Requires-Python: >=3.6,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Provides-Extra: aio
Requires-Dist: aiohttp (>=3.6.2,<4.0.0) ; extra == "aio"
Project-URL: Repository, https://github.com/gera2ld/pyserve
Description-Content-Type: text/x-rst

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'))

