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

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
分享
二维码
< <上一篇
下一篇>>