gpt4 book ai didi

python - 带有 after_request 的基本 flask 应用程序返回服务器错误

转载 作者:太空宇宙 更新时间:2023-11-04 01:04:09 25 4
gpt4 key购买 nike

from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello():
return "k?"
@app.after_request
def sendsms():
pass
if __name__ == '__main__':
app.run()

我做错了什么?或者我理解 after_request 是错误的吗?如果是的话,我非常感谢您的解释。

最佳答案

documentation通常是寻找此类问题答案的好地方。

Your function must take one parameter, a response_class object and return a new response object or the same (see process_response()).

您的函数不会做这些事情。

@app.after_request
def sendsms(response):
return response

关于python - 带有 after_request 的基本 flask 应用程序返回服务器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31283188/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com