Getting application error while running the python app on heroku

落花浮王杯 提交于 2021-02-11 12:34:03

问题


I am trying to deploy a simple python app to heroku but I am getting application error while running the command "heroku open".

Below is the list of files and folders in my root directory of the application.

Inside my Procfile, I have written the below code:

      web: gunicorn script1:app

This is the first time I am trying to deploy the app to heroku. Below is the sequence of commands I am using for the same:

  1. Create 3 files in my root folder, requirements.txt, Procfile, runtime.txt.
  2. Open command prompt, navigate to root folder, run command "heroku login" - Login successful after providing the email.
  3. "heroku create myappname" - Created the app successfully.
  4. "git init" - Created the .git folder in my root path.
  5. "git add ." - Added all the files in the current directory to the git repository successfuly.
  6. "git config --global user.email "myemail@gmail.com" - Successfully authenticated.
  7. "git config --global user.name "username"
  8. "git commit -m "first commit""
  9. "heroku git:remote --app myappname"
  10. "git push heroku master" - Successfully detected and deployed the app with a message: Verifying deploy... done.
  11. "heroku open" - Whenever I run this command I get Application error.

Everything went smoothly till step 10. But, whenever I try opening the app, it gives application error in the browser.

I searched the internet and tried 2 solutions but none of them worked for me:

  1. To run the command before opening heroku - "heroku ps:scale web=1"

  2. To change the run method in the scripts file as :

     if __name__ == "__main__":
                port = int(os.environ.get("PORT", 5000))
                app.run(host="0.0.0.0", port=port)
    

I don't know what I am doing wrong, any help would be greatly appreciated.

Screenshot of error:

Logs:

heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" status=503

来源:https://stackoverflow.com/questions/64364849/getting-application-error-while-running-the-python-app-on-heroku

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!