环境
macOS 10.14.6
Python 3.7.7
httpie
httpie 是一个命令行 HTTP 客户端。
安装httpie
- 安装
1 | $ brew install httpie |
这里使用 homebrew 安装 httpie。
- 查看版本
1 | $ http --version |
代码
1 | # -*- coding:utf-8 -*- |
创建 server.py,内容如上。
运行
- 启动服务器
1 | $ python server.py & |
&表示将这个任务放到后台去执行。
- get 请求
1 | $ http 0.0.0.0:8080/home.html |
- post 请求
1 | $ http 0.0.0.0:8080 hello=world |