解决方法
Flask在请求对象中附带一个is_xhr属性.
from flask import request @app.route('/',methods=['GET','POST']) def home_page(): if request.is_xhr: context = controllers.get_default_context() return render_template('home.html',**context)