flask TypeError'dict'object is not callableの解決
693 ワード
flaskでlistまたはdictを直接返すと'dict'object is not callableのエラーが発生します
flaskはlistまたはdictをデフォルトでjsonフォーマットに変換できないためです.方法1:flask_を導入するjsonのas_jsonは以下のように解決できます.
参照 Flask設定jsonフォーマットデータを返す
@user_bp.route('/help',methods=['GET'])
def show_user_help():
help_path= "help.pdf"
print('help_path:',help_path)
return dict(download_help_path=help_path)
flaskはlistまたはdictをデフォルトでjsonフォーマットに変換できないためです.方法1:flask_を導入するjsonのas_jsonは以下のように解決できます.
from flask_json import as_json
@user_bp.route('/help',methods=['GET'])
@as_json
def show_user_help():
help_path= "help.pdf"
print('help_path:',help_path)
return dict(download_help_path=help_path)
参照