Deploying a flask app to Heroku can somehow become a hustle! Even when you have done everything the right way,the famous H10 Heroku error can just pop up out of nowhere!
Here is a way that makes deployment less of a hustle and more of a win!
- - Navigate to your config file,config.py, ensure that the DEBUG = True is in the same line as class DevConfig(Config):
class DevConfig(Config):
DEBUG = True
Create a Procfile, then add: < web: gunicorn manage:app> In this case, app is your application name and manage is the file you're using to run the code
Login to your Heroku account or create a new one:< heroku login >
Next create the app: heroku create <name-of-app>
If you have API or secret key>> heroku config:set API_KEY= <your-api-key>
Install the following(in virtual) if you haven’t: (remember to use pip install):
- Flask 1.1.4
- Gunicorn
- Argcomplete 2.0.0
- MarkUpsafe 2.0.1
- Django-cors-header 3.11.0
Generate a requirements.txt using: pip freeze > requirements.txt
Create a runtime.txt in the project root folder file and add then python version you’re using: For example: python-3.9.12
On terminal, run heroku config:set DISABLE_COLLECTSTATIC=1
--->Lastly, 1.Git add . =>2. Git Commit -m ”deployment updates” => 3.Git push heroku main/master(depending on your branch name)
Remember: A new bug after fixing the previous one is progress… Happy Hacking!
Top comments (0)