测试开发技术栈
后端开发技术
安装核心插件
pip install flask
pip install flask-restful
pip install flask-sqlalchemy
pip install pymysql
pip install flask-jwt-extended
直接启动
if __name__ == '__main__':
app.run(debug=True)
测试
curl -H "content-type: application/json" \
http://127.0.0.1:5000/login -d '{"username": "seveniruby", "password": "hogwarts"}'
{
"errcode": 0,
"errmsg": "ok",
"username": "seveniruby",
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MDA3ODAxNjcsIm5iZiI6MTYwMDc4MDE2NywianRpIjoiZTAzNjdkNTctZDA0NC00ZjEwLThiZTEtYjBiY2JlMWM0MDMyIiwiZXhwIjoxNjAwNzgxMDY3LCJpZGVudGl0eSI6InNldmVuaXJ1YnkiLCJmcmVzaCI6ZmFsc2UsInR5cGUiOiJhY2Nlc3MifQ.WMLZzO_zY3qWn8DRdqqUZgnuUAc6GAZSDsHr7Y3a3nU"
}
#TOKEN="eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2MDA3ODAxNjcsIm5iZiI6MTYwMDc4MDE2NywianRpIjoiZTAzNjdkNTctZDA0NC00ZjEwLThiZTEtYjBiY2JlMWM0MDMyIiwiZXhwIjoxNjAwNzgxMDY3LCJpZGVudGl0eSI6InNldmVuaXJ1YnkiLCJmcmVzaCI6ZmFsc2UsInR5cGUiOiJhY2Nlc3MifQ.WMLZzO_zY3qWn8DRdqqUZgnuUAc6GAZSDsHr7Y3a3nU"
curl -H "content-type: application/json" -H "Authorization: Bearer $TOKEN" \
http://127.0.0.1:5000/testcase
curl -H "content-type: application/json" -H "Authorization: Bearer $TOKEN" \
http://127.0.0.1:5000/task -d '{"testcases": "demo" }'
演练代码
https://github.com/ceshiren/backend_service_python_14
相关链接
https://flask.palletsprojects.com/en/1.1.x/
https://flask-sqlalchemy.palletsprojects.com/en/2.x/
https://flask-jwt-extended.readthedocs.io/en/latest/
https://flask-restful.readthedocs.io/en/latest/quickstart.html#
https://flask-cors.readthedocs.io/en/latest/