我在python上运行以下代码:
from flask import Flask
app = Flask(__name__)
@app.route('/', methods=['GET'])
def verify():
if request.args.get("hub.mode") == "subscribe" and request.args.get("hub.challenge"):
if not request.args.get("hub.verify_token") ==
os.environ ["VERIFY_TOKEN"]:
return "Verification token mismatch", 403
return request.args["hub.challenge"], 200
return "Hello world", 200
if __name__ == "__main__":
app.run(debug=True)
并收到此错误:
NameError:名称'request'未定义
答案 0 :(得分:1)
您需要导入flask.request
:
from flask import request