mini program for suna 接口文檔

API

2019.8.10.

http://18.220.98.204:80/suna/index

  • 自測結果
    自測結果

  • “微信開發者工具”中允許使用ip地址測試的設置方法如下:
    在這裏插入圖片描述

2019.8.15. post api test

  • unit test result is as following:
 $ curl http://18.220.98.204:80/suna/index -X POST -d '{"user":"suna","password":"123456"}' -H "Content-Type:application/json" -v
Note: Unnecessary use of -X or --request, POST is already inferred.
*   Trying 18.220.98.204...
* TCP_NODELAY set
* Connected to 18.220.98.204 (18.220.98.204) port 80 (#0)
> POST /suna/index HTTP/1.1
> Host: 18.220.98.204
> User-Agent: curl/7.54.0
> Accept: */*
> Content-Type:application/json
> Content-Length: 35
> 
* upload completely sent off: 35 out of 35 bytes
* HTTP 1.0, assume close after body
< HTTP/1.0 200 OK
< Content-Type: application/json
< Content-Length: 98
< Server: Werkzeug/0.15.2 Python/3.6.7
< Date: Thu, 15 Aug 2019 14:05:16 GMT
< 
{"code":200,"data":{"password":"123456","user":"suna"},"msg":"hello suna!","request_type":"POST"}
* Closing connection 0

2019.8.18

post 出錯。
主要原因是如果content-type不爲josn的時候,request裏數據是存在data裏的,不能通過get_json拿到。
需要修改爲:

    data = request.get_data()
    json_data = json.loads(data.decode("utf-8"))
    req = json_data

但是如果content-type修改爲json之後,request.get_json直接就可以取到了。
使用微信小程序測試通過:
在這裏插入圖片描述

2019.9.7 學習專業RESTFUL API文檔的寫法

參考API鏈接:http://bl.7yue.pro/dev/index.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章