HTTP and Flask Basics - Introduction to Curl and Chrome Dev Tools

Chrome Dev Tools
If you want to check how your requests are being sent, and what the responses are from the browser, you can do so using Chrome Dev Tools. There are numerous tools within it, but the key area you will use is the Network tab.


Curl
请添加图片描述
Curl is a library and command-line tool that completes IP transfers of data using URLs. One quick way to test your API while your API server is running is to run a curl command in another terminal window.

Curl syntax

$ curl -X POST http://www.example.com/tasks/

The above is a sample curl request. Every request starts off with the command curl and needs to include a URL. Other parts you see added in are options that you can use to build your request. In the example, the -X shortform option (also –request) specifies the request method.

请添加图片描述
Curl Options
You can find more options by entering the following command in the terminal:

$ curl --help

Try piping the output to the jq, a command-line JSON processor, as shown below:

$ curl https://example/test | jq '.'

如果在Terminal显示不了,可以用这个网站来看JSON result
查询curl结果

Art of Scripting HTTP Requests Using Curl

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值