code: def redirect_to_ssl(self):
          
          # Should we redirect?
          criteria = [
              request.is_secure,
              current_app.debug,
              current_app.testing,
              request.headers.get('X-Forwarded-Proto', 'http') == 'https'
          ]
  
          if not any(criteria) and not self.skip:
              if request.url.startswith('http://'):
                  url = request.url.replace('http://', 'https://', 1)
                  code = 302
                  if self.permanent:
                      code = 301
                  r = redirect(url, code=code)
                  return r
docs: Redirect incoming requests to HTTPS.