提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
前言
一、Flask响应_数据的响应,返回数据的响应
代码如下(示例):
from flask import Flask
app = Flask(__name__)
@app.route('/str')
def index():
return '你好,少年'
app.config['JSON_AS_ASCII'] = False
@app.route('/json1')
def r_json():
return {'key':'python语言'}
from flask import jsonify
@app.route('/json2')
def r_json2():
return jsonify({'key':'python语言'})
@app.route('/tuple')
def r_tuple():
# return 'tuple',202
# return 'tuple',{'canshu':'python'}
# return 'tuple',300,{'canshu':'python'}
return 'tuple',300,[('canshu','python_sql')]
if __name__ =='__main__':
app.run(debug=True)