当前位置: 首页 > 工具软件 > HTTPie > 使用案例 >

HTTPie安装使用

毕富
2023-12-01

启动后端服务,通过httpie测试一下自己写的接口
httpie是一个命令行形式的http客户端,它提供了简单的http命令,返回带代码高亮的结果信息,可以很方便的在http交互场景下进行测试、调试等。
安装httpie
Windows

pip install --upgrade httpie
Linux

apt-get install httpie
macOS

brew install httpie
通过调用接口向Django App中添加两条书名记录。

```shell
➜  http http://127.0.0.1:8000/api/add_book\?book_name\=mikezhou_talk
HTTP/1.1 200 OK
Content-Length: 34
Content-Type: application/json
Date: Sun, 15 Dec 2019 09:11:12 GMT
Server: WSGIServer/0.2 CPython/3.7.4
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
{
    "error_num": 0,
    "msg": "success"
}
 
 
 
 
 ➜  http http://127.0.0.1:8000/api/add_book\?book_name\=测试开发技术
HTTP/1.1 200 OK
Content-Length: 34
Content-Type: application/json
Date: Sun, 15 Dec 2019 09:11:44 GMT
Server: WSGIServer/0.2 CPython/3.7.4
X-Content-Type-Options: nosniff
X-Frame-Options: DENY
{
    "error_num": 0,
    "msg": "success"
}


参考
https://zhuanlan.zhihu.com/p/45093545
 类似资料: