Flask#

To deploy a Flask application in Ploomber Cloud you need:

  • A Ploomber Cloud account

  • Your application file (app.py)

  • A dependencies file (requirements.txt)

Important

In your app, you must initialize your app like this:

# app.py: must assign the app to a variable named "app"!
app = Flask(__name__)

Furthermore, you should not call app.run():

See here a basic Flask app example.

Testing locally#

To test your app, you can use gunicorn locally:

# Install requirements
pip install -r requirements.txt

# Start the flask application
gunicorn app:app run --bind 0.0.0.0:5000

Now, open http://0.0.0.0:5000/ to see your app.

Deploy#

Deploy from the menu

Once you have all your files, create a zip file.

To deploy a Flask app from the deployment menu, follow these instructions:

Try an example

To download and deploy an example Flask application start by installing Ploomber Cloud and setting your API key:

pip install ploomber-cloud
ploomber-cloud key YOUR-KEY

Tip

If you don’t have an API key yet, follow the instructions here.

Now, download an example. It will prompt you for a location to download the app. To download in the current directory, just press enter.

ploomber-cloud examples flask/basic-app

Note

A full list of Flask example apps is available here.

You should see a confirmation with instructions on deploying your app. Now, navigate to your application:

cd location-you-entered/basic-app

Deploy from the CLI

Initialize and deploy your app with:

ploomber-cloud init
ploomber-cloud deploy --watch

Tip

To ensure your app doesn’t break on re-deployments, pin your dependencies.

Features#

Ploomber Cloud supports many features to help you build Flask applications quickly!

Examples#