Flask - Security Best Practices
You want to add multiple secure headers in Flask, but only for HTTPS requests. Which is the best way to do this securely and efficiently?
@app.after_request runs after response creation and can access request.is_secure to conditionally add headers efficiently for all routes.@app.before_request cannot modify response headers.@app.after_request to check request.is_secure and add headers conditionally -> Option A@app.after_request is best [OK]request.is_secure in @app.after_request [OK]@app.before_request which can't modify response15+ quiz questions · All difficulty levels · Free
Free Signup - Practice All Questions