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

发布了83 篇原创文章 · 获赞 4 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/hope_worker/article/details/98658444