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

2019-06-27 20:11:47 +08:00
 prasanta

项目地址:

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。 自己动手,丰衣足食。

1632 次点击
所在节点    Python
3 条回复
rust
2019-06-29 23:43:26 +08:00
项目地址 404 了
astro1boy
2020-02-16 01:34:29 +08:00
404 了什么情况?不是挺好的么?不打算写下去了?
astro1boy
2020-02-16 01:36:22 +08:00
看到了,改名 gain 了啊 https://github.com/gaojiuli/gain

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/578121

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX