I created a flask app for my cs50 final project. It was successfully deployed to Heroku via Github, but for some reason it's not working.
When running locally with flask run
it works fine though.
My project folder is organized like this
The Procfile content is the following:
web: gunicorn app:app
I guess it's right, according to this helpful post.
Following heroku's instructions I ran heroku logs --tail --app [APP]
to see what's the problem
Here's the error message I get:
at=error code=H14 desc="No web processes running" method=GET path="/" host=joking.herokuapp.com request_id=029d94b3-938c-4623-8421-7246c2ba52dc fwd="177.104.215.5" dyno= connect= service= status=503 bytes= protocol=https
Why would it say that there are no web processes running, when I clearly defined it in the Procfile?
Besides, I searched the net (look at these posts for example: A, B and C) and oftenly people solved this by running heroku ps:scale web=1
I did that but unfortunatelly it didn't solve the problem. Here's the message it returns:
Scaling dynos... done, now running web at 1:Free
So it seems that the dynos scaling are OK.
What could be the problem then? Am I missing something?
I'm accepting any suggestions. Maybe there's something wrong with my code? Or the way that files and folders are organized? Gunicorn?
Here you can check out the github repository with all the code (Please don't mind the poor README.md file, I'm still gonna write a good one)
I deployed your app on my heroku. There was no error like no web proccess running
.
You can see whether any dyno is attached by going on overview tab of heroku.
Still the gunicorn worker failed to boot. The reason is that you are not defining host and port parameters in app.run()
it should be like this:
if __name__ == "__main__":
port = int(os.environ.get("PORT", 5000))
app.run(host="0.0.0.0",port=port)
Second thing I noticed is that you are using sqlite (db file) for database.
heroku doesn't support sqlite worker restart overtime and all the file come in the state on which they were deployed any uploaded file or updated file will be lost. here is the resources.
Heroku has postgresql database which can be used but then you need to use psgcopg2(I am not clear about it) or use flask-sqlalchemy
which support variety of databases.
You can find several articles and videos to deploy app with postgresql.
In the same way you will not be able to save profile_pics of users in heroku. You can use firebase storage system with pyrebase package for uploading files to server. docs
You can visit the deployed app here.