python - Flask Heroku Staging and Production builds -
i new python, , wondering if there way can manage profiles staging or production ? best way other changing code every time ?
there no "best" way pretty in programming (since "best" subjective idea, , every programmer , project different), since you've thrown on heroku tag, assume need way works on heroku. therefore, give the advice heroku gives you:
a given codebase may have numerous deployments: production site, staging site, , number of local environments maintained each developer. open source app may have hundreds or thousands of deployments.
although running same code, each of these deploys have environment-specific configurations. 1 example credentials external service, such amazon s3. developers may share 1 s3 account, while staging site , production sites each have own keys.
the traditional approach handling such config vars put them under source - in properties file of sort. error-prone process, , complicated open source apps have maintain separate (and private) branches app-specific configurations.
a better solution use environment variables, , keep keys out of code.
how set environment variables application in development environment dependent on platform running on (setting environment variables different between linux , windows, example). should @ heroku docs more info.
in code, use os.environ
dictionary retrieve environment variables.
Comments
Post a Comment