How to Deploy Flask App to App Platform


I am new to web app deployment, and am attempting to deploy a Flask web app to the DigitalOcean App Platform — but am having a hard time finding the right documentation.

I have a working Flask app on my local machine in the form of a Python package, where I can run the file to launch the app. The code in the file looks like this:

from website import create_app

app = create_app()

if __name__ == '__main__':

The file references code in the file, which looks like this:

from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from os import path
from flask_login import LoginManager

db = SQLAlchemy()
DB_NAME = 'database.db'

def create_app():
	app = Flask(__name__)
	app.config['SQLALCHEMY_DATABASE_URI'] = f'sqlite:///{DB_NAME}'

	from .views import views
	from .auth import auth

	app.register_blueprint(views, url_prefix='/')
	app.register_blueprint(auth, url_prefix='/')

	from .models import User, Security


	login_manager = LoginManager()
	login_manager.login_view = 'auth.login'

	def load_user(id):


def create_database(app):
	if not path.exists('website/' + DB_NAME):
		print('Created Database!')

The rest of the code (templates, models, etc.) is kept throughout the package in other folders or files. My file structure looks like this:

  - requirements.txt
  - website
     - (authorization routes)
     - (regular routes)
     - (defines SQL classes)
     - database.db (SQL database)
     - static
        - index.js (holds JavaScript functions)
        - styles
           - styles.css (holds CSS)
     - templates
        - ALL SITE TEMPLATES (.html)

I have successfully followed the instructions in this link ( to upload my app to a Github repository, but am unsure what to specify for the build commands and run commands on the App Platform setup, as well as if this structure will work at all on the App Platform.

Thank you in advance for any help.

Submit an answer

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!

Sign In or Sign Up to Answer

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.

Hello @jonleff

The flask app with this structure should work on the App Platform. There is no need to add the build command however you can add the following run command to deploy the app:

gunicorn --worker-tmp-dir /dev/shm --config --bind main:app

If you are seeing any issue with deploying the app with above run command then please contact support with exact error message and we will be able to assist you.

Thank you!

Best, Dikshith