Skip to content
Advertisement

Configure Python Flask RESTplus app via TOML file

Based on the Configuration Handling Documents for Flask the section of Configuring from Files mentions a possibility to configure the App using files however it provides no example or mention of files that are not Python Files.

Is it possible to configure apps via files like config.yml or config.toml?

My Current flask app has configurations for two distinct databases and since I am using flask-restplus there are additional configurations for Swagger documentations.

Snippet:

JavaScript

I would like to avoid setting large number of Environment Variables and wish to configure them using a config.toml file?

How is this achieved in flask?

Advertisement

Answer

You can use the .cfg files and from_envvar to achieve this. Create config file with all your environment variables.

my_config.cfg

JavaScript

Then set the env var APP_ENVS=my_config.cfg. Now all you need to do is use from_envvars given by Flask.

JavaScript
Advertisement