V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
prasanta
V2EX  ›  Python

AsHTTP: 异步 HTTP 客户端,我们不等 Requests3.0 了。

  •  
  •   prasanta · 2019-06-27 20:11:47 +08:00 · 1619 次点击
    这是一个创建于 1758 天前的主题,其中的信息可能已经有所发展或是发生改变。

    项目地址:

    https://github.com/gaojiuli/ashttp

    简介

    最近开发后端都是使用的异步框架,遇到发送 HTTP 请求的时候,我都是使用的 aiohttp,但是我发现它的用法实在是有点不舒服。于是我参考 requests 的 API 实现了基于 asyncio 的异步 HTTP client。

    安装

    pip install ashttp -i https://pypi.org/simple
    

    用法

    import asyncio
    from ashttp import *
    
    async def main():
        await get('https://httpbin.org/get')
        await post('https://httpbin.org/post', data=json.dumps({"a": 1}))
        await put('https://httpbin.org/put', data=json.dumps({"a": 1}))
        await patch('https://httpbin.org/patch', data=json.dumps({"a": 1}))
        await delete('https://httpbin.org/delete')
        await option('https://httpbin.org/option')
        
    asyncio.run(main())
    

    附言

    希望有兴趣的同学一起参与进来,实现一套好用的异步 HTTP 客户端。我们不等 Requests3.0。 自己动手,丰衣足食。

    3 条回复    2020-02-16 01:36:22 +08:00
    rust
        1
    rust  
       2019-06-29 23:43:26 +08:00 via Android
    项目地址 404 了
    astro1boy
        2
    astro1boy  
       2020-02-16 01:34:29 +08:00
    404 了什么情况?不是挺好的么?不打算写下去了?
    astro1boy
        3
    astro1boy  
       2020-02-16 01:36:22 +08:00
    看到了,改名 gain 了啊 https://github.com/gaojiuli/gain
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2813 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 12:35 · PVG 20:35 · LAX 05:35 · JFK 08:35
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.