2024-05-28 20:53:13 发布
网友
我有以下路线:
@app.route("/my_page") @app.route("/my_page.json") def targets(): # .....
如果是一个简单的http请求,我希望返回一个html模板;如果是ajax请求,并且路由以“.json”结尾,则返回json。我怎么确定呢?我试过访问“请求”,但没有。在
如前所述,in the documentation,您需要导入请求才能使用它。在
from flask import request ... def targets(): if request.is_xhr(): ...
如前所述,in the documentation,您需要导入请求才能使用它。在
相关问题 更多 >
编程相关推荐