Setting Environment Variables
You can set environment variables to define the appropriate behavior for the live app on Plotly Cloud.
In the example above, the app might be written to behave differently depending on whether the app is running locally or elsewhere (the value of IS_LOCAL
). With this environment variable set in Plotly Cloud, IS_LOCAL=false
is added to the live app environment, where the app can retrieve it with os.environ.get()
and execute the appropriate code.
Environment variables that you set for your app are applied at runtime.
Adding environment variables
Environment variable names have a maximum character length of 255 and are automatically turned into uppercase. If your environment variables names contain more than one word and you want to separate them, be sure to use underscores. Spaces are not supported.
To add an environment variable:
- Go to your app Settings
.
- Go to the General tab.
- In Environment variables, select Edit
.
- Select Add variable.
- Enter a name and value for your environment variable. Environment variables are case sensitive, so references in the app code need to match exactly what you enter.
- Select Save and restart. A new revision is created with the applied change.
Editing environment variables
You can change the names and values of environment variables after you've added them.
To edit an environment variable:
- Go to your app Settings
.
- Go to the General tab.
- In Environment variables, select Edit
.
- Edit the environment variable name and/or value. Environment variables are case sensitive, so references in the app code need to match exactly what you enter.
- Select Save and restart. A new revision is created with the applied change.
Deleting environment variables
To delete an environment variable:
- Go to your app Settings
.
- Go to the General tab.
- In Environment variables, select Edit
.
- Next to the environment variable that you want to delete, select Delete
.
- Select Save and restart. A new revision is created with the applied change.