Commits

Anonymous committed 6e7141f

Provide a correct initial environ in case the user has set 'SERVER_NAME' on his app's configuration.

  • Participants
  • Parent commits 7ce0bd3

Comments (0)

Files changed (1)

File flaskext/script.py

         Handles the command with given app. Default behaviour is to call within
         a test request context.
         """
-        with app.test_request_context():
+        environ_base = {}
+        if app.config.get('SERVER_NAME'):
+            server_name = app.config.get('SERVER_NAME', 'localhost:80')
+            http_host, http_port = server_name.split(':')
+            environ_base['SERVER_NAME'] = server_name
+            environ_base['HTTP_HOST'] = server_name
+            environ_base['SERVER_PORT'] = http_port
+
+        with app.test_request_context(environ_base=environ_base):
             self.run(*args, **kwargs)
 
     def run(self):