通过Get& amp;发布方法

时间:2016-12-23 15:43:32

标签: python api url curl post

我正在学习如何使用Python和Flask开发传统的API。这是我第一次。截至目前,我可以做两件事。我可以GET和POST。问题是,我可以使用Postman的cURL进行GET和POST。

GET

 curl -i http://localhost:5000/api/v1.0/test

它返回200 OK JSON

POST

curl -i -H "Content-Type: application/json" -X POST -d '{"input":"This is heavy Doc"}' http://localhost:5000/api/v1.0/test

以JSON格式返回:

"Status" : "200 OK",
"Input": "This is heavy Doc"

我将注意力转移到了浏览器和HTTP上,从我的实验中,我只需输入以下内容即可获得GET:

 http://localhost:5000/api/v1.0/cite 

它返回了预期的结果。但我正在做的非常困难的事情是将POST cURL转录为我可以在浏览器中传递的HTTP请求。我遇到了几个堆栈的答案,答案是:它不可能。

如果是这种情况,例如Google如何使用以下网址查询:

https://maps.googleapis.com/maps/api/distancematrix/json?origins=Vancouver+BC|Seattle&destinations=San+Francisco|Victoria+BC&key=YOUR_API_KEY

0 个答案:

没有答案
相关问题