0

im trying to learn how to fetch API using python-flask with heroku as the cloud service

in the app, there's a key to communicate with the source server and i set the config variable (config vars) like

X_App_APIKeys = {key strings}

how can i use the variable as an object in my code?

i.e : myapikeys = X_App_APIKeys

Horando
  • 5
  • 1
  • 1
    Does this answer your question? [setting environment variables in heroku for flask app](https://stackoverflow.com/questions/28323666/setting-environment-variables-in-heroku-for-flask-app) – Gino Mempin Jun 11 '22 at 07:48

1 Answers1

0

Simply import os

Then myapikeys = os.environ['X_App_APIKeys']

Notice that this only works on the live app deployed on Heroku when the config has been set up. To run your local instance, replace it with your real key instead.

Ethan
  • 346
  • 1
  • 5