def _force_https():
    if not app.debug:
        from flask import _request_ctx_stack
if _request_ctx_stack is not None:
    reqctx = _request_ctx_stack.top
reqctx.url_adapter.url_scheme = 'https'
app.before_request(_force_https)
Make Flask's url_for use the 'https' scheme in an AWS load balancer without messing with SSLify