Prerequisites
Before deploying, ensure you have:- A Heroku account
- Heroku CLI installed
- Git installed on your local machine
- Your application code in a Git repository
Deployment Steps
Login to Heroku
Open your terminal and authenticate with Heroku:This will open a browser window for you to complete the authentication.
Create a Heroku App
Create a new Heroku application:
Replace
your-app-name with your desired application name. If you omit the name, Heroku will generate a random one.Configure Environment Variables
Set up the required environment variables for your application:For Gmail, you’ll need to generate an App Password instead of using your regular password.
Deploy the Application
Push your code to Heroku:Heroku will automatically detect the Python application, install dependencies from
If your default branch is named
master instead of main, use git push heroku master.requirements.txt, and start the app using the Procfile configuration.Understanding the Procfile
The application includes aProcfile that tells Heroku how to run your app:
Procfile
- Defines a
webprocess type - Uses Gunicorn as the WSGI HTTP server (production-ready)
- Points to the Flask application instance (
app:apprefers to theappvariable inapp.py)
Post-Deployment Configuration
Setting Up the Scheduler
The application uses APScheduler to send automated reminders at 8:00 AM. In production on Heroku, you may need to consider timezone settings:Replace
America/Mexico_City with your appropriate timezone. The scheduler is configured in app.py:88-91 to trigger at 8:00 AM local time.Data Persistence
The application stores data in JSON files in thedata/ directory. For production use, consider:
Monitoring and Logs
View Application Logs
Monitor your application in real-time:Check Dyno Status
Verify your application is running:Troubleshooting
Application Crashes
Check the logs for errors:Common issues:
- Missing environment variables
- Incorrect Python version
- Missing dependencies in
requirements.txt
Scheduler Not Running
The APScheduler may not work correctly on Heroku’s free dynos due to sleeping. Consider:
- Upgrading to a paid dyno
- Using Heroku Scheduler addon
- Implementing a webhook-based solution
Email Sending Fails
Verify your email configuration:Ensure:
- MAIL_USERNAME and MAIL_PASSWORD are correct
- You’re using a Gmail App Password (not regular password)
- Two-factor authentication is enabled on your Gmail account