Merge pull request #573 from r0fls/env-config

allow setting config from individual env variables
This commit is contained in:
Eli Uriegas
2017-03-28 22:24:37 -05:00
committed by GitHub
4 changed files with 37 additions and 3 deletions

View File

@@ -29,6 +29,14 @@ In general the convention is to only have UPPERCASE configuration parameters. Th
There are several ways how to load configuration.
### From environment variables.
Any variables defined with the `SANIC_` prefix will be applied to the sanic config. For example, setting `SANIC_REQUEST_TIMEOUT` will be loaded by the application automatically. You can pass the `load_vars` boolean to the Sanic constructor to override that:
```python
app = Sanic(load_vars=False)
```
### From an Object
If there are a lot of configuration values and they have sensible defaults it might be helpful to put them into a module: