Skip to content

Instantly share code, notes, and snippets.

@m5wdev
Last active March 25, 2019 19:03
Show Gist options
  • Save m5wdev/7b6dc55864d2039ebf4449bdd9da174e to your computer and use it in GitHub Desktop.
Save m5wdev/7b6dc55864d2039ebf4449bdd9da174e to your computer and use it in GitHub Desktop.
Flask redirect from http:// to https://
# 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