Using envvault with Python/Flask
Note: Please ensure that you have completed the previous steps
Prerequisites
- Python installed on your system
- envvault CLI tool installed
- An existing Python/Flask project
Usage
Running Your Application
To run your Python application with environment variables from envvault:
$ envvault run --env=dev python app.pyCaching Environment Variables
For better performance, you can cache your environment variables:
$ envvault run --env=dev -c -- python app.pyExample Implementation
Here is how to set up a basic Flask application with envvault:
# app.py
from flask import Flask
import os
app = Flask(__name__)
# Your environment variables are automatically loaded
PORT = os.getenv('PORT', 5000)
DB_URL = os.getenv('DB_URL')
@app.route('/')
def hello():
    return 'Hello from envvault!'
if __name__ == '__main__':
    app.run(port=PORT)