进大厂,身价翻倍的法宝来了!
主讲内容:docker/kubernetes 云原生技术,大数据架构,分布式微服务,自动化测试、运维。
视频地址:ke.qq.com/course/419718
在python后台——asyncio,aiohttp入门教程,多进程+asyncio文章中,我们介绍了asyncio,aiohttp的入门知识,现在我们这里详细介绍一下aiohttp
参考文档:https://www.bookstack.cn/read/aiohttp-chinese-documentation/aiohttp%E6%96%87%E6%A1%A3-ServerTutorial.md
aiohttp.web建立在这几个概念之上: 应用(application),路由(router),请求(request)和响应(response)。
底层服务器
aiohttp是基于asyncio来实现的。如果不是需要和其他的异步进程一块使用,我们一般用不到这么底层的实现方法。
import asyncio
from aiohttp import web
async def handler(request):
return web.Response(text="OK")
async def main(loop):
server = web.Server(handler)