Skip to content

Commit

Permalink
add readme
Browse files Browse the repository at this point in the history
  • Loading branch information
mosquito committed Jul 31, 2018
1 parent f588a07 commit f18b847
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,43 @@ Running and graceful shutdown multiple services in one process.
loop.run_forever()
Service for aiohttp
-------------------

Installed aiohttp required.

.. code-block:: python
import aiohttp.web
from aiomisc.entrypoint import entrypoint
from aiomisc.service.aiohttp import AIOHTTPService
async def handle(request):
name = request.match_info.get('name', "Anonymous")
text = "Hello, " + name
return aiohttp.web.Response(text=text)
class REST(AIOHTTPService):
async def create_application(self):
app = aiohttp.web.Application()
app.add_routes([
aiohttp.web.get('/', handle),
aiohttp.web.get('/{name}', handle)
])
return app
service = REST(address='127.0.0.1', port=8080)
with entrypoint(service) as loop:
loop.run_forever()
threaded decorator
------------------
Expand Down

0 comments on commit f18b847

Please sign in to comment.