code: def _force_https(self):
          
  
          if self.session_cookie_secure:
              if not self.app.debug:
                  self.app.config['SESSION_COOKIE_SECURE'] = True
  
          criteria = [
              self.app.debug,
              flask.request.is_secure,
              flask.request.headers.get('X-Forwarded-Proto', 'http') == 'https',
          ]
  
          local_options = self._get_local_options()
  
          if local_options['force_https'] and not any(criteria):
              if flask.request.url.startswith('http://'):
                  url = flask.request.url.replace('http://', 'https://', 1)
                  code = 302
                  if self.force_https_permanent:
                      code = 301
                  r = flask.redirect(url, code=code)
                  return r
docs: Redirect any non-https requests to https.
  
          Based largely on flask-sslify.