Where should I place the secret key in Flask?

后端 未结 2 2032
忘掉有多难
忘掉有多难 2020-11-27 22:25

While reading exploreflask.com, I learned that it is best practice to use two different config files, one for development and one for production. I don\'t understand whether

2条回答
  •  萌比男神i
    2020-11-27 22:47

    I use a mixture of hardcoded values and environment variables in my production config.py:

    import os
    
    
    class Config(object):
        SECRET_KEY = os.environ.get("SECRET_KEY")
        SQLALCHEMY_DATABASE_URI = os.environ.get("DB_PROD")
        SQLALCHEMY_TRACK_MODIFICATIONS = False
    

    In my development config.py, eveything is hardcoded.

提交回复
热议问题