I’ve changed somethings on my local Flask app to adapt it when deploying like installing gunicorn and adding:
"if __name__ == "__main__":
app.run(host='0.0.0.0', port=os.environ.get('PORT', 8080))"
to properly run my webapp. After a successful deployment I go to the default DigitalOcean url for the app and I see this message: “We encountered an error when trying to load your application and your page could not be served. Check the logs for your application in the App Platform dashboard.”
In my runtime logs I just see this:
[bookingssite] [2024-05-09 13:44:11] [2024-05-09 13:44:11 +0000] [1] [INFO] Listening at: http://0.0.0.0:8080 (1)
[bookingssite] [2024-05-09 13:44:11] [2024-05-09 13:44:11 +0000] [1] [INFO] Using worker: sync
[bookingssite] [2024-05-09 13:44:12] [2024-05-09 13:44:12 +0000] [18] [INFO] Booting worker with pid: 18
and then a lot of booting workers. This is how I load my sqlite database:
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' + os.path.join(basedir, 'data.sqlite')
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
db = SQLAlchemy(app)
Migrate(app,db)
I’ve also selected the right port when setting up the app platform. What’s the problem here?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hey!
I think that the issue might be with the SQLite database. The storage on the DigitalOcean App Platform is ephemeral, meaning that every time you do a new deployment, anything that you’ve stored on the local storage will be lost.
For persistent data, you should consider using an actual database instead like a Managed Postgres instance or the App Platform dev databases:
Let me know how it goes!
Best,
Bobby