Kris
Kris

Reputation: 10317

Accessing Environment Variables in Google App Engine

Just wondering locally, I could access environment variables within google app engine? For example, I've stored an email and password and would like to access it like this:

import os

email = os.environ.get("EMAIL")
password = os.environ.get("PASSWORD")

Is there any way to do this?

Upvotes: 2

Views: 2849

Answers (1)

Jeff Deskins
Jeff Deskins

Reputation: 1660

You can define variables in app.yaml to make them available to the os.environ dictionary:

env_variables:
  EMAIL: '[email protected]'

Then access the variable with:

email = os.environ.get("EMAIL")

More info is in the documentation.

Upvotes: 2

Related Questions