Quantcast
Channel: Active questions tagged config - Stack Overflow
Viewing all articles
Browse latest Browse all 5049

.env File or a Config Class

$
0
0

Is there a reason why I would use the following:

from flask import Flaskimport stripeclass Config():    STRIPE_SECRET_KEY = 'stripe-secret-key'app = Flask(__name__)app.config.from_object(Config)stripe.api_key = app.config['STRIPE_SECRET_KEY']

rather than populating the .env file with export STRIPE_SECRET_KEY="stripe-secret-key" and then using:

from environs import Envfrom flask import Flaskimport stripeenv = Env()env.read_env()stripe.api_key = env.str('STRIPE_SECRET_KEY')

i.e. why wouldn't I just store all environment variables in the Config class, rather than a .env file? Is it more secure to use a .env file?

Thanks for any help here :-)


Viewing all articles
Browse latest Browse all 5049

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>