Created
July 17, 2019 13:37
-
-
Save le717/a7b1d396d5dd9bbecb5d8b51a34a3acf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@current_app.before_request | |
def detect_ie_browser(): | |
"""Redirect all IE visitors to a special page | |
informing them to get a web browser. | |
""" | |
# For this to work, the following conditions must be met: | |
# 1. The visitor is using IE (doesn't matter what version) | |
# 2. We must not be currently requesting a static file | |
# (we still need page styles/resources to load) | |
# 3. We don't need to be directly requesting the special page | |
# (we create an endless redirect loop) | |
if ( | |
request.user_agent.browser == "msie" and | |
request.endpoint != "static" and | |
request.endpoint != "special.unsupported_browser" | |
): | |
return redirect(url_for("special.unsupported_browser")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment