Asynchronous HTTP Client/Server for asyncio and Python.
Create a Virtual environment with Python3
$ pip install virtualenv // install library
$ python -m virtualenv -p python3 venv // creating virtual environment
$ source venv/bin/activate // activating virtual environment
Install library
$ pip install aiohttp
$ pip install aiohttp
Create Server:
from aiohttp import web
async def handle(request):
name = request.match_info.get('name', "Anonymous")
text = "Hello, " + name
return web.Response(text=text)
app = web.Application()
app.add_routes([web.get('/', handle),
web.get('/{name}', handle)])
if __name__ == '__main__':
web.run_app(app)