python/flask get/post 不同请求头格式
如下:```pythonfrom flask import requestimport flaskserver = flask.Flask(__name__)@server.route('/argslogin', methods=['get'])def test_args():#表单格式ad = request.args.get('admin')ps = request.args['ps']pri
·
如下:
```python
from flask import request
import flask
server = flask.Flask(__name__)
@server.route('/argslogin', methods=['get'])
def test_args():
#表单格式
ad = request.args.get('admin')
ps = request.args['ps']
print(ad,ps)
return {'ad':ad,'ps':ps}
@server.route('/jsonlogin', methods=['post'])
def test_josn():
#json格式
ad = request.json.get('admin')
ps = request.json['ps']
print(ad,ps)
return {'ad':ad,'ps':ps}
@server.route('/formlogin', methods=['post'])
def test_form():
#表单格式
ad = request.form.get('admin')
ps = request.form['ps']
print(ad,ps)
return {'ad':ad,'ps':ps}
if __name__ == '__main__':
server.run(debug=True, host='0.0.0.0', port=8080)
更多推荐
已为社区贡献1条内容
所有评论(0)