def _force_https(app):

    def wrapper(environ, start_response):
        environ['wsgi.url_scheme'] = 'https'
return app(environ, start_response)
return wrapper
Flask url_for generating http URL instead of https