Knowledgebase

Managing Environment Variables Print

  • python, database, errors, guide, howto, solution, zillionkinghost, hosting
  • 0

Configuration for hosted applications.

WHAT THEY ARE

Values available to your application from its environment, rather than from its code.

WHY USE THEM

Secrets stay out of code and out of version control The same code runs in development and production

WHAT TO PUT IN THEM

Database credentials API keys Any setting that differs between environments A flag indicating the environment

WHERE TO SET THEM

The Python application interface provides a place for them.

WHAT TO DO AFTER CHANGING ONE

Restart the application.

WHAT TO DO IN YOUR CODE

Read them, and fail clearly at startup if a required one is missing.

WHY FAIL AT STARTUP

Better than failing obscurely on the first request that needs it.

WHAT TO PROVIDE FOR DEVELOPMENT

A local file holding the same values, excluded from version control.

WHAT TO COMMIT

An example file with placeholder values.

WHAT NEVER TO DO

Commit real values Log environment variables Display them in error output


Was this answer helpful?
Back

Are you happy with your experience? Leave us a review on Trustpilot.


Trustpilot