Overview
Environment variables allow you to:- Keep sensitive credentials out of source code
- Use different configurations for development, staging, and production
- Deploy the same codebase to multiple environments
- Follow security best practices
Required Variables
Application Secret Key
Secret key used for session management and security features.Default (Development):
clave_secreta_muy_segura (see app.py:13)Production: Generate a strong random key:Email Configuration
The application uses Flask-Mail for sending automated reminder emails. Configuration is set inapp.py:15-21.
SMTP server hostname for sending emails.Default:
smtp.gmail.comCommon values:- Gmail:
smtp.gmail.com - Outlook:
smtp.office365.com - SendGrid:
smtp.sendgrid.net - Custom SMTP: Your server hostname
SMTP server port number.Default:
587Common values:587- TLS (recommended)465- SSL25- Unencrypted (not recommended)
Enable TLS encryption for email connections.Default:
TrueTLS is recommended for secure email transmission. Set to
True when using port 587.Email account username for SMTP authentication.Default (Development):
[email protected] (see app.py:19)Production: Use your actual email addressPassword or app-specific password for SMTP authentication.Default (Development):
mcgc unmv wkci dbrr (see app.py:20)Security Note: The default value is a Gmail app password format and should be replaced with your own.Optional Variables
Server Configuration
Flask environment mode.Values:
development- Debug mode enabled, detailed errorsproduction- Optimized for production, minimal output
The application sets
debug=True in app.py:239 for local development. Override this with environment variables in production.Port number for the application server.Default:
5000 (see app.py:239)Heroku: Automatically set via $PORT variableHost address to bind the server.Default:
0.0.0.0 (see app.py:239)Values:0.0.0.0- Accept connections from any IP127.0.0.1- Local connections only
Scheduler Configuration
Hour of day (24-hour format) to send automated reminders.Default:
8 (8:00 AM - see app.py:90)Range: 0-23Minute of hour to send automated reminders.Default:
0 (see app.py:90)Range: 0-59Timezone for the scheduler.Heroku Example:
Configuration Methods
Method 1: Environment Variables (Recommended)
Set environment variables directly in your shell or hosting platform:Method 2: .env File (Development Only)
Create a.env file in your project root:
.env
Method 3: Using python-dotenv
To automatically load.env files, install python-dotenv:
app.py:
Reading Environment Variables in Code
The current implementation uses hardcoded values inapp.py:13-20. To use environment variables, update your code:
Platform-Specific Configuration
Heroku
View all configured variables:Docker
Pass environment variables via Docker:.env file:
systemd (Linux Services)
Add to your service file:/etc/systemd/system/checawaa.service
Security Best Practices
Use Different Secrets Per Environment
Development, staging, and production should have completely different secret keys.
Rotate Credentials Regularly
Change passwords and secret keys periodically, especially after team member changes.
Example Configurations
Development
.env.development
Production
Production (Heroku)
Troubleshooting
Environment Variables Not Loading
Solution:
- Verify variable names are correct (case-sensitive)
- Restart your application after setting variables
- Check that
.envfile is in the project root - Ensure
python-dotenvis installed if using.envfiles
Email Authentication Fails
Solution:
- Use Gmail App Password (not regular password)
- Enable 2FA on your Google account
- Check MAIL_USERNAME and MAIL_PASSWORD are correctly set
- Verify MAIL_SERVER and MAIL_PORT are correct
Scheduler Timezone Issues
Solution:
- Set the TZ environment variable explicitly
- Use IANA timezone names (e.g.,
America/Mexico_City) - Restart the application after changing timezone
- Check logs to verify scheduler triggers at correct time
Next Steps
Local Setup
Configure your local development environment
Deploy to Heroku
Deploy with environment variables