We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Configs loaded from environmental variables aren't properly typed
When setting configs using environmental variables `export SANIC_REQUEST_TIMEOUT=30`

```
app = Sanic(__name__)
print(type(app.config.REQUEST_TIMEOUT))  #  <class 'str'>
```

The problem is in this function
```
# .../sanic/config.py
    def load_environment_vars(self):
        """
        Looks for any SANIC_ prefixed environment variables and applies
        them to the configuration if present.
        """
        for k, v in os.environ.items():
            if k.startswith(SANIC_PREFIX):
                _, config_key = k.split(SANIC_PREFIX, 1)
                self[config_key] = v  # os.environ values are always of type str
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `sanic/config.py`
Content:
```
1 import os
2 import sys
3 import syslog
4 import platform
5 import types
6 
7 from sanic.log import DefaultFilter
8 
9 SANIC_PREFIX = 'SANIC_'
10 
11 _address_dict = {
12     'Windows': ('localhost', 514),
13     'Darwin': '/var/run/syslog',
14     'Linux': '/dev/log',
15     'FreeBSD': '/dev/log'
16 }
17 
18 LOGGING = {
19     'version': 1,
20     'filters': {
21         'accessFilter': {
22             '()': DefaultFilter,
23             'param': [0, 10, 20]
24         },
25         'errorFilter': {
26             '()': DefaultFilter,
27             'param': [30, 40, 50]
28         }
29     },
30     'formatters': {
31         'simple': {
32             'format': '%(asctime)s - (%(name)s)[%(levelname)s]: %(message)s',
33             'datefmt': '%Y-%m-%d %H:%M:%S'
34         },
35         'access': {
36             'format': '%(asctime)s - (%(name)s)[%(levelname)s][%(host)s]: ' +
37                       '%(request)s %(message)s %(status)d %(byte)d',
38             'datefmt': '%Y-%m-%d %H:%M:%S'
39         }
40     },
41     'handlers': {
42         'internal': {
43             'class': 'logging.StreamHandler',
44             'filters': ['accessFilter'],
45             'formatter': 'simple',
46             'stream': sys.stderr
47         },
48         'accessStream': {
49             'class': 'logging.StreamHandler',
50             'filters': ['accessFilter'],
51             'formatter': 'access',
52             'stream': sys.stderr
53         },
54         'errorStream': {
55             'class': 'logging.StreamHandler',
56             'filters': ['errorFilter'],
57             'formatter': 'simple',
58             'stream': sys.stderr
59         },
60         # before you use accessSysLog, be sure that log levels
61         # 0, 10, 20 have been enabled in you syslog configuration
62         # otherwise you won't be able to see the output in syslog
63         # logging file.
64         'accessSysLog': {
65             'class': 'logging.handlers.SysLogHandler',
66             'address': _address_dict.get(platform.system(),
67                                          ('localhost', 514)),
68             'facility': syslog.LOG_DAEMON,
69             'filters': ['accessFilter'],
70             'formatter': 'access'
71         },
72         'errorSysLog': {
73             'class': 'logging.handlers.SysLogHandler',
74             'address': _address_dict.get(platform.system(),
75                                          ('localhost', 514)),
76             'facility': syslog.LOG_DAEMON,
77             'filters': ['errorFilter'],
78             'formatter': 'simple'
79         },
80     },
81     'loggers': {
82         'sanic': {
83             'level': 'DEBUG',
84             'handlers': ['internal', 'errorStream']
85         },
86         'network': {
87             'level': 'DEBUG',
88             'handlers': ['accessStream', 'errorStream']
89         }
90     }
91 }
92 
93 # this happens when using container or systems without syslog
94 # keep things in config would cause file not exists error
95 _addr = LOGGING['handlers']['accessSysLog']['address']
96 if type(_addr) is str and not os.path.exists(_addr):
97     LOGGING['handlers'].pop('accessSysLog')
98     LOGGING['handlers'].pop('errorSysLog')
99 
100 
101 class Config(dict):
102     def __init__(self, defaults=None, load_env=True, keep_alive=True):
103         super().__init__(defaults or {})
104         self.LOGO = """
105                  ▄▄▄▄▄
106         ▀▀▀██████▄▄▄       _______________
107       ▄▄▄▄▄  █████████▄  /                 \\
108      ▀▀▀▀█████▌ ▀▐▄ ▀▐█ |   Gotta go fast!  |
109    ▀▀█████▄▄ ▀██████▄██ | _________________/
110    ▀▄▄▄▄▄  ▀▀█▄▀█════█▀ |/
111         ▀▀▀▄  ▀▀███ ▀       ▄▄
112      ▄███▀▀██▄████████▄ ▄▀▀▀▀▀▀█▌
113    ██▀▄▄▄██▀▄███▀ ▀▀████      ▄██
114 ▄▀▀▀▄██▄▀▀▌████▒▒▒▒▒▒███     ▌▄▄▀
115 ▌    ▐▀████▐███▒▒▒▒▒▐██▌
116 ▀▄▄▄▄▀   ▀▀████▒▒▒▒▄██▀
117           ▀▀█████████▀
118         ▄▄██▀██████▀█
119       ▄██▀     ▀▀▀  █
120      ▄█             ▐▌
121  ▄▄▄▄█▌              ▀█▄▄▄▄▀▀▄
122 ▌     ▐                ▀▀▄▄▄▀
123  ▀▀▄▄▀
124 """
125         self.REQUEST_MAX_SIZE = 100000000  # 100 megabytes
126         self.REQUEST_TIMEOUT = 60  # 60 seconds
127         self.KEEP_ALIVE = keep_alive
128         self.WEBSOCKET_MAX_SIZE = 2 ** 20  # 1 megabytes
129         self.WEBSOCKET_MAX_QUEUE = 32
130 
131         if load_env:
132             self.load_environment_vars()
133 
134     def __getattr__(self, attr):
135         try:
136             return self[attr]
137         except KeyError as ke:
138             raise AttributeError("Config has no '{}'".format(ke.args[0]))
139 
140     def __setattr__(self, attr, value):
141         self[attr] = value
142 
143     def from_envvar(self, variable_name):
144         """Load a configuration from an environment variable pointing to
145         a configuration file.
146 
147         :param variable_name: name of the environment variable
148         :return: bool. ``True`` if able to load config, ``False`` otherwise.
149         """
150         config_file = os.environ.get(variable_name)
151         if not config_file:
152             raise RuntimeError('The environment variable %r is not set and '
153                                'thus configuration could not be loaded.' %
154                                variable_name)
155         return self.from_pyfile(config_file)
156 
157     def from_pyfile(self, filename):
158         """Update the values in the config from a Python file.
159         Only the uppercase variables in that module are stored in the config.
160 
161         :param filename: an absolute path to the config file
162         """
163         module = types.ModuleType('config')
164         module.__file__ = filename
165         try:
166             with open(filename) as config_file:
167                 exec(compile(config_file.read(), filename, 'exec'),
168                      module.__dict__)
169         except IOError as e:
170             e.strerror = 'Unable to load configuration file (%s)' % e.strerror
171             raise
172         self.from_object(module)
173         return True
174 
175     def from_object(self, obj):
176         """Update the values from the given object.
177         Objects are usually either modules or classes.
178 
179         Just the uppercase variables in that object are stored in the config.
180         Example usage::
181 
182             from yourapplication import default_config
183             app.config.from_object(default_config)
184 
185         You should not use this function to load the actual configuration but
186         rather configuration defaults. The actual config should be loaded
187         with :meth:`from_pyfile` and ideally from a location not within the
188         package because the package might be installed system wide.
189 
190         :param obj: an object holding the configuration
191         """
192         for key in dir(obj):
193             if key.isupper():
194                 self[key] = getattr(obj, key)
195 
196     def load_environment_vars(self):
197         """
198         Looks for any SANIC_ prefixed environment variables and applies
199         them to the configuration if present.
200         """
201         for k, v in os.environ.items():
202             if k.startswith(SANIC_PREFIX):
203                 _, config_key = k.split(SANIC_PREFIX, 1)
204                 self[config_key] = v
205
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/sanic/config.py b/sanic/config.py
--- a/sanic/config.py
+++ b/sanic/config.py
@@ -201,4 +201,10 @@
         for k, v in os.environ.items():
             if k.startswith(SANIC_PREFIX):
                 _, config_key = k.split(SANIC_PREFIX, 1)
-                self[config_key] = v
+                try:
+                    self[config_key] = int(v)
+                except ValueError:
+                    try:
+                        self[config_key] = float(v)
+                    except ValueError:
+                        self[config_key] = v

{"golden_diff": "diff --git a/sanic/config.py b/sanic/config.py\n--- a/sanic/config.py\n+++ b/sanic/config.py\n@@ -201,4 +201,10 @@\n         for k, v in os.environ.items():\n             if k.startswith(SANIC_PREFIX):\n                 _, config_key = k.split(SANIC_PREFIX, 1)\n-                self[config_key] = v\n+                try:\n+                    self[config_key] = int(v)\n+                except ValueError:\n+                    try:\n+                        self[config_key] = float(v)\n+                    except ValueError:\n+                        self[config_key] = v\n", "issue": "Configs loaded from environmental variables aren't properly typed\nWhen setting configs using environmental variables `export SANIC_REQUEST_TIMEOUT=30`\r\n\r\n```\r\napp = Sanic(__name__)\r\nprint(type(app.config.REQUEST_TIMEOUT))  #  <class 'str'>\r\n```\r\n\r\nThe problem is in this function\r\n```\r\n# .../sanic/config.py\r\n    def load_environment_vars(self):\r\n        \"\"\"\r\n        Looks for any SANIC_ prefixed environment variables and applies\r\n        them to the configuration if present.\r\n        \"\"\"\r\n        for k, v in os.environ.items():\r\n            if k.startswith(SANIC_PREFIX):\r\n                _, config_key = k.split(SANIC_PREFIX, 1)\r\n                self[config_key] = v  # os.environ values are always of type str\r\n```\r\n\n", "before_files": [{"content": "import os\nimport sys\nimport syslog\nimport platform\nimport types\n\nfrom sanic.log import DefaultFilter\n\nSANIC_PREFIX = 'SANIC_'\n\n_address_dict = {\n    'Windows': ('localhost', 514),\n    'Darwin': '/var/run/syslog',\n    'Linux': '/dev/log',\n    'FreeBSD': '/dev/log'\n}\n\nLOGGING = {\n    'version': 1,\n    'filters': {\n        'accessFilter': {\n            '()': DefaultFilter,\n            'param': [0, 10, 20]\n        },\n        'errorFilter': {\n            '()': DefaultFilter,\n            'param': [30, 40, 50]\n        }\n    },\n    'formatters': {\n        'simple': {\n            'format': '%(asctime)s - (%(name)s)[%(levelname)s]: %(message)s',\n            'datefmt': '%Y-%m-%d %H:%M:%S'\n        },\n        'access': {\n            'format': '%(asctime)s - (%(name)s)[%(levelname)s][%(host)s]: ' +\n                      '%(request)s %(message)s %(status)d %(byte)d',\n            'datefmt': '%Y-%m-%d %H:%M:%S'\n        }\n    },\n    'handlers': {\n        'internal': {\n            'class': 'logging.StreamHandler',\n            'filters': ['accessFilter'],\n            'formatter': 'simple',\n            'stream': sys.stderr\n        },\n        'accessStream': {\n            'class': 'logging.StreamHandler',\n            'filters': ['accessFilter'],\n            'formatter': 'access',\n            'stream': sys.stderr\n        },\n        'errorStream': {\n            'class': 'logging.StreamHandler',\n            'filters': ['errorFilter'],\n            'formatter': 'simple',\n            'stream': sys.stderr\n        },\n        # before you use accessSysLog, be sure that log levels\n        # 0, 10, 20 have been enabled in you syslog configuration\n        # otherwise you won't be able to see the output in syslog\n        # logging file.\n        'accessSysLog': {\n            'class': 'logging.handlers.SysLogHandler',\n            'address': _address_dict.get(platform.system(),\n                                         ('localhost', 514)),\n            'facility': syslog.LOG_DAEMON,\n            'filters': ['accessFilter'],\n            'formatter': 'access'\n        },\n        'errorSysLog': {\n            'class': 'logging.handlers.SysLogHandler',\n            'address': _address_dict.get(platform.system(),\n                                         ('localhost', 514)),\n            'facility': syslog.LOG_DAEMON,\n            'filters': ['errorFilter'],\n            'formatter': 'simple'\n        },\n    },\n    'loggers': {\n        'sanic': {\n            'level': 'DEBUG',\n            'handlers': ['internal', 'errorStream']\n        },\n        'network': {\n            'level': 'DEBUG',\n            'handlers': ['accessStream', 'errorStream']\n        }\n    }\n}\n\n# this happens when using container or systems without syslog\n# keep things in config would cause file not exists error\n_addr = LOGGING['handlers']['accessSysLog']['address']\nif type(_addr) is str and not os.path.exists(_addr):\n    LOGGING['handlers'].pop('accessSysLog')\n    LOGGING['handlers'].pop('errorSysLog')\n\n\nclass Config(dict):\n    def __init__(self, defaults=None, load_env=True, keep_alive=True):\n        super().__init__(defaults or {})\n        self.LOGO = \"\"\"\n                 \u2584\u2584\u2584\u2584\u2584\n        \u2580\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2584\u2584       _______________\n      \u2584\u2584\u2584\u2584\u2584  \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584  /                 \\\\\n     \u2580\u2580\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u258c \u2580\u2590\u2584 \u2580\u2590\u2588 |   Gotta go fast!  |\n   \u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2584\u2584 \u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2588\u2588 | _________________/\n   \u2580\u2584\u2584\u2584\u2584\u2584  \u2580\u2580\u2588\u2584\u2580\u2588\u2550\u2550\u2550\u2550\u2588\u2580 |/\n        \u2580\u2580\u2580\u2584  \u2580\u2580\u2588\u2588\u2588 \u2580       \u2584\u2584\n     \u2584\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2584\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2584\u2580\u2580\u2580\u2580\u2580\u2580\u2588\u258c\n   \u2588\u2588\u2580\u2584\u2584\u2584\u2588\u2588\u2580\u2584\u2588\u2588\u2588\u2580 \u2580\u2580\u2588\u2588\u2588\u2588      \u2584\u2588\u2588\n\u2584\u2580\u2580\u2580\u2584\u2588\u2588\u2584\u2580\u2580\u258c\u2588\u2588\u2588\u2588\u2592\u2592\u2592\u2592\u2592\u2592\u2588\u2588\u2588     \u258c\u2584\u2584\u2580\n\u258c    \u2590\u2580\u2588\u2588\u2588\u2588\u2590\u2588\u2588\u2588\u2592\u2592\u2592\u2592\u2592\u2590\u2588\u2588\u258c\n\u2580\u2584\u2584\u2584\u2584\u2580   \u2580\u2580\u2588\u2588\u2588\u2588\u2592\u2592\u2592\u2592\u2584\u2588\u2588\u2580\n          \u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\n        \u2584\u2584\u2588\u2588\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2588\n      \u2584\u2588\u2588\u2580     \u2580\u2580\u2580  \u2588\n     \u2584\u2588             \u2590\u258c\n \u2584\u2584\u2584\u2584\u2588\u258c              \u2580\u2588\u2584\u2584\u2584\u2584\u2580\u2580\u2584\n\u258c     \u2590                \u2580\u2580\u2584\u2584\u2584\u2580\n \u2580\u2580\u2584\u2584\u2580\n\"\"\"\n        self.REQUEST_MAX_SIZE = 100000000  # 100 megabytes\n        self.REQUEST_TIMEOUT = 60  # 60 seconds\n        self.KEEP_ALIVE = keep_alive\n        self.WEBSOCKET_MAX_SIZE = 2 ** 20  # 1 megabytes\n        self.WEBSOCKET_MAX_QUEUE = 32\n\n        if load_env:\n            self.load_environment_vars()\n\n    def __getattr__(self, attr):\n        try:\n            return self[attr]\n        except KeyError as ke:\n            raise AttributeError(\"Config has no '{}'\".format(ke.args[0]))\n\n    def __setattr__(self, attr, value):\n        self[attr] = value\n\n    def from_envvar(self, variable_name):\n        \"\"\"Load a configuration from an environment variable pointing to\n        a configuration file.\n\n        :param variable_name: name of the environment variable\n        :return: bool. ``True`` if able to load config, ``False`` otherwise.\n        \"\"\"\n        config_file = os.environ.get(variable_name)\n        if not config_file:\n            raise RuntimeError('The environment variable %r is not set and '\n                               'thus configuration could not be loaded.' %\n                               variable_name)\n        return self.from_pyfile(config_file)\n\n    def from_pyfile(self, filename):\n        \"\"\"Update the values in the config from a Python file.\n        Only the uppercase variables in that module are stored in the config.\n\n        :param filename: an absolute path to the config file\n        \"\"\"\n        module = types.ModuleType('config')\n        module.__file__ = filename\n        try:\n            with open(filename) as config_file:\n                exec(compile(config_file.read(), filename, 'exec'),\n                     module.__dict__)\n        except IOError as e:\n            e.strerror = 'Unable to load configuration file (%s)' % e.strerror\n            raise\n        self.from_object(module)\n        return True\n\n    def from_object(self, obj):\n        \"\"\"Update the values from the given object.\n        Objects are usually either modules or classes.\n\n        Just the uppercase variables in that object are stored in the config.\n        Example usage::\n\n            from yourapplication import default_config\n            app.config.from_object(default_config)\n\n        You should not use this function to load the actual configuration but\n        rather configuration defaults. The actual config should be loaded\n        with :meth:`from_pyfile` and ideally from a location not within the\n        package because the package might be installed system wide.\n\n        :param obj: an object holding the configuration\n        \"\"\"\n        for key in dir(obj):\n            if key.isupper():\n                self[key] = getattr(obj, key)\n\n    def load_environment_vars(self):\n        \"\"\"\n        Looks for any SANIC_ prefixed environment variables and applies\n        them to the configuration if present.\n        \"\"\"\n        for k, v in os.environ.items():\n            if k.startswith(SANIC_PREFIX):\n                _, config_key = k.split(SANIC_PREFIX, 1)\n                self[config_key] = v\n", "path": "sanic/config.py"}], "after_files": [{"content": "import os\nimport sys\nimport syslog\nimport platform\nimport types\n\nfrom sanic.log import DefaultFilter\n\nSANIC_PREFIX = 'SANIC_'\n\n_address_dict = {\n    'Windows': ('localhost', 514),\n    'Darwin': '/var/run/syslog',\n    'Linux': '/dev/log',\n    'FreeBSD': '/dev/log'\n}\n\nLOGGING = {\n    'version': 1,\n    'filters': {\n        'accessFilter': {\n            '()': DefaultFilter,\n            'param': [0, 10, 20]\n        },\n        'errorFilter': {\n            '()': DefaultFilter,\n            'param': [30, 40, 50]\n        }\n    },\n    'formatters': {\n        'simple': {\n            'format': '%(asctime)s - (%(name)s)[%(levelname)s]: %(message)s',\n            'datefmt': '%Y-%m-%d %H:%M:%S'\n        },\n        'access': {\n            'format': '%(asctime)s - (%(name)s)[%(levelname)s][%(host)s]: ' +\n                      '%(request)s %(message)s %(status)d %(byte)d',\n            'datefmt': '%Y-%m-%d %H:%M:%S'\n        }\n    },\n    'handlers': {\n        'internal': {\n            'class': 'logging.StreamHandler',\n            'filters': ['accessFilter'],\n            'formatter': 'simple',\n            'stream': sys.stderr\n        },\n        'accessStream': {\n            'class': 'logging.StreamHandler',\n            'filters': ['accessFilter'],\n            'formatter': 'access',\n            'stream': sys.stderr\n        },\n        'errorStream': {\n            'class': 'logging.StreamHandler',\n            'filters': ['errorFilter'],\n            'formatter': 'simple',\n            'stream': sys.stderr\n        },\n        # before you use accessSysLog, be sure that log levels\n        # 0, 10, 20 have been enabled in you syslog configuration\n        # otherwise you won't be able to see the output in syslog\n        # logging file.\n        'accessSysLog': {\n            'class': 'logging.handlers.SysLogHandler',\n            'address': _address_dict.get(platform.system(),\n                                         ('localhost', 514)),\n            'facility': syslog.LOG_DAEMON,\n            'filters': ['accessFilter'],\n            'formatter': 'access'\n        },\n        'errorSysLog': {\n            'class': 'logging.handlers.SysLogHandler',\n            'address': _address_dict.get(platform.system(),\n                                         ('localhost', 514)),\n            'facility': syslog.LOG_DAEMON,\n            'filters': ['errorFilter'],\n            'formatter': 'simple'\n        },\n    },\n    'loggers': {\n        'sanic': {\n            'level': 'DEBUG',\n            'handlers': ['internal', 'errorStream']\n        },\n        'network': {\n            'level': 'DEBUG',\n            'handlers': ['accessStream', 'errorStream']\n        }\n    }\n}\n\n# this happens when using container or systems without syslog\n# keep things in config would cause file not exists error\n_addr = LOGGING['handlers']['accessSysLog']['address']\nif type(_addr) is str and not os.path.exists(_addr):\n    LOGGING['handlers'].pop('accessSysLog')\n    LOGGING['handlers'].pop('errorSysLog')\n\n\nclass Config(dict):\n    def __init__(self, defaults=None, load_env=True, keep_alive=True):\n        super().__init__(defaults or {})\n        self.LOGO = \"\"\"\n                 \u2584\u2584\u2584\u2584\u2584\n        \u2580\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2584\u2584       _______________\n      \u2584\u2584\u2584\u2584\u2584  \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584  /                 \\\\\n     \u2580\u2580\u2580\u2580\u2588\u2588\u2588\u2588\u2588\u258c \u2580\u2590\u2584 \u2580\u2590\u2588 |   Gotta go fast!  |\n   \u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2584\u2584 \u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2584\u2588\u2588 | _________________/\n   \u2580\u2584\u2584\u2584\u2584\u2584  \u2580\u2580\u2588\u2584\u2580\u2588\u2550\u2550\u2550\u2550\u2588\u2580 |/\n        \u2580\u2580\u2580\u2584  \u2580\u2580\u2588\u2588\u2588 \u2580       \u2584\u2584\n     \u2584\u2588\u2588\u2588\u2580\u2580\u2588\u2588\u2584\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2584 \u2584\u2580\u2580\u2580\u2580\u2580\u2580\u2588\u258c\n   \u2588\u2588\u2580\u2584\u2584\u2584\u2588\u2588\u2580\u2584\u2588\u2588\u2588\u2580 \u2580\u2580\u2588\u2588\u2588\u2588      \u2584\u2588\u2588\n\u2584\u2580\u2580\u2580\u2584\u2588\u2588\u2584\u2580\u2580\u258c\u2588\u2588\u2588\u2588\u2592\u2592\u2592\u2592\u2592\u2592\u2588\u2588\u2588     \u258c\u2584\u2584\u2580\n\u258c    \u2590\u2580\u2588\u2588\u2588\u2588\u2590\u2588\u2588\u2588\u2592\u2592\u2592\u2592\u2592\u2590\u2588\u2588\u258c\n\u2580\u2584\u2584\u2584\u2584\u2580   \u2580\u2580\u2588\u2588\u2588\u2588\u2592\u2592\u2592\u2592\u2584\u2588\u2588\u2580\n          \u2580\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2580\n        \u2584\u2584\u2588\u2588\u2580\u2588\u2588\u2588\u2588\u2588\u2588\u2580\u2588\n      \u2584\u2588\u2588\u2580     \u2580\u2580\u2580  \u2588\n     \u2584\u2588             \u2590\u258c\n \u2584\u2584\u2584\u2584\u2588\u258c              \u2580\u2588\u2584\u2584\u2584\u2584\u2580\u2580\u2584\n\u258c     \u2590                \u2580\u2580\u2584\u2584\u2584\u2580\n \u2580\u2580\u2584\u2584\u2580\n\"\"\"\n        self.REQUEST_MAX_SIZE = 100000000  # 100 megabytes\n        self.REQUEST_TIMEOUT = 60  # 60 seconds\n        self.KEEP_ALIVE = keep_alive\n        self.WEBSOCKET_MAX_SIZE = 2 ** 20  # 1 megabytes\n        self.WEBSOCKET_MAX_QUEUE = 32\n\n        if load_env:\n            self.load_environment_vars()\n\n    def __getattr__(self, attr):\n        try:\n            return self[attr]\n        except KeyError as ke:\n            raise AttributeError(\"Config has no '{}'\".format(ke.args[0]))\n\n    def __setattr__(self, attr, value):\n        self[attr] = value\n\n    def from_envvar(self, variable_name):\n        \"\"\"Load a configuration from an environment variable pointing to\n        a configuration file.\n\n        :param variable_name: name of the environment variable\n        :return: bool. ``True`` if able to load config, ``False`` otherwise.\n        \"\"\"\n        config_file = os.environ.get(variable_name)\n        if not config_file:\n            raise RuntimeError('The environment variable %r is not set and '\n                               'thus configuration could not be loaded.' %\n                               variable_name)\n        return self.from_pyfile(config_file)\n\n    def from_pyfile(self, filename):\n        \"\"\"Update the values in the config from a Python file.\n        Only the uppercase variables in that module are stored in the config.\n\n        :param filename: an absolute path to the config file\n        \"\"\"\n        module = types.ModuleType('config')\n        module.__file__ = filename\n        try:\n            with open(filename) as config_file:\n                exec(compile(config_file.read(), filename, 'exec'),\n                     module.__dict__)\n        except IOError as e:\n            e.strerror = 'Unable to load configuration file (%s)' % e.strerror\n            raise\n        self.from_object(module)\n        return True\n\n    def from_object(self, obj):\n        \"\"\"Update the values from the given object.\n        Objects are usually either modules or classes.\n\n        Just the uppercase variables in that object are stored in the config.\n        Example usage::\n\n            from yourapplication import default_config\n            app.config.from_object(default_config)\n\n        You should not use this function to load the actual configuration but\n        rather configuration defaults. The actual config should be loaded\n        with :meth:`from_pyfile` and ideally from a location not within the\n        package because the package might be installed system wide.\n\n        :param obj: an object holding the configuration\n        \"\"\"\n        for key in dir(obj):\n            if key.isupper():\n                self[key] = getattr(obj, key)\n\n    def load_environment_vars(self):\n        \"\"\"\n        Looks for any SANIC_ prefixed environment variables and applies\n        them to the configuration if present.\n        \"\"\"\n        for k, v in os.environ.items():\n            if k.startswith(SANIC_PREFIX):\n                _, config_key = k.split(SANIC_PREFIX, 1)\n                try:\n                    self[config_key] = int(v)\n                except ValueError:\n                    try:\n                        self[config_key] = float(v)\n                    except ValueError:\n                        self[config_key] = v\n", "path": "sanic/config.py"}]}