Last active
March 25, 2019 19:03
-
-
Save m5wdev/7b6dc55864d2039ebf4449bdd9da174e to your computer and use it in GitHub Desktop.
Flask redirect from http:// to https://
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
# Redirect to https | |
@app.before_request | |
def before_request(): | |
if request.url.startswith('http://'): | |
url = request.url.replace('http://', 'https://', 1) | |
return redirect(url, code=301) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment