zoukankan      html  css  js  c++  java
  • aiohttp

    aiohttp

    GitHub路径

    https://github.com/aio-libs/aiohttp#client

    安装

    pip install --user aiohttp
    

    demo

    #-*-coding:utf-8-*-
    #@author    :vict
    #@Time      :2020-10-29 15:36
    #@File      :aiohttpserver
    #@software  :PyCharm
    from aiohttp import web
    from aiohttp_session import get_session
    
    
    async def handle(request):
        name = request.match_info.get('name', "Anonymous")
        text = "Hello, " + name
        return web.Response(text=text)
    
    async def post_handler(request):
        sheader = str(request.headers)
        print(sheader)
        data = await request.read()
        sBody = str(data, encoding='utf8')
        print(sBody)
    
    
    app = web.Application()
    app.add_routes([web.get('/', handle),
                    web.get('/{name}', handle),
                    web.post('/monitorCollection/laneHeartbeat', post_handler),
                    web.post('/monitorCollection/trafficRecord', post_handler),
                    web.post('/monitorCollection/laneChargeVersion', post_handler),
                    web.post('/monitorCollection/laneHardwareInfo', post_handler),
                    web.post('/monitorCollection/appHeartbeat', post_handler),
                    web.post('/monitorCollection/warningUpload', post_handler),
                    web.post('/monitorCollection/laneDeviceInfoUpload', post_handler)])
    
    if __name__ == '__main__':
        web.run_app(app, host='127.0.0.1', port=8284)
    

    示例代码链接
    链接:https://pan.baidu.com/s/1NDp2C1NRcLx6YZsPe9-gKQ
    提取码:i2ia

  • 相关阅读:
    uniapp跨域
    uniapp图片文件转base64
    懒加载
    修改富文本样式
    搜集到的常用Scheme
    JS浏览器复制
    程序员必须知道的六大ES6新特性
    详解ES6中的 let 和const
    数据库基础
    配置环境变量
  • 原文地址:https://www.cnblogs.com/huanyinglvtuan/p/13903677.html
Copyright © 2011-2022 走看看