How can I identify requests made via AJAX in Python's Flask?
Flask comes with a is_xhr
attribute in the request
object.
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)
Notice: This solution is deprecated and not viable anymore.