DEV Community

Millicent A. Obwanda
Millicent A. Obwanda

Posted on

How To Deploy A python-flask app to Heroku. Avoid the [H10-Error] !

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!

  1. - 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
Enter fullscreen mode Exit fullscreen mode
  1. 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

  2. Login to your Heroku account or create a new one:< heroku login >

  3. Next create the app: heroku create <name-of-app>

  4. If you have API or secret key>> heroku config:set API_KEY= <your-api-key>

  5. 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
  1. Generate a requirements.txt using: pip freeze > requirements.txt

  2. Create a runtime.txt in the project root folder file and add then python version you’re using: For example: python-3.9.12

  3. 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)