> ## Documentation Index
> Fetch the complete documentation index at: https://www.aptible.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Python + Flask - Demo App

> Deploy our Python demo app using the Flask framework with Managed PostgreSQL Database and Redis instance

<CardGroup cols={3}>
  <Card title="Deploy Now" icon="rocket" href="https://app.aptible.com/create" />

  <Card title="GitHub Repo" icon="github" href="https://github.com/aptible/deploy-demo-app" />

  <Card title="View Example" icon="browser" href="https://app-60388.on-aptible.com/" />
</CardGroup>

# Overview

The following guide is designed to help you deploy an example app on Aptible. During this process, Aptible will launch containers to run a Python app with a web server, a background worker, a Managed PostgreSQL Database, and a Redis instance.

<Frame>
  <img src="https://mintcdn.com/aptible/2c_c-XH-dAzVOaDu/images/flask1.png?fit=max&auto=format&n=2c_c-XH-dAzVOaDu&q=85&s=0627d26b6502fbfb650fc62e2ec920c6" alt="" width="3200" height="1600" data-path="images/flask1.png" />
</Frame>

The demo app displays the last 20 messages of the database, including any additional messages you record via the "message board." The application was designed to guide new users through a "Setup Checklist" which showcases various features of the Aptible platform (such as database migration, scaling, etc.) using both the dashboard and Aptible CLI.

# Deploy App

<Info> Prerequisite: Ensure you have [Git](https://git-scm.com/downloads) installed. </Info>

Using the [Deploy Code](https://app.aptible.com/create) tool in the Aptible Dashboard, you can deploy the **Deploy Demo App**. The tool will guide you through the following:

<Steps>
  <Step title="Deploy with Git Push">
    <img src="https://mintcdn.com/aptible/2c_c-XH-dAzVOaDu/images/flask2.png?fit=max&auto=format&n=2c_c-XH-dAzVOaDu&q=85&s=fca1202761392674e0e50f2afa05cc8a" alt="" width="2000" height="1000" data-path="images/flask2.png" />
  </Step>

  <Step title="Add an SSH key">
    <img src="https://mintcdn.com/aptible/2c_c-XH-dAzVOaDu/images/flask3.png?fit=max&auto=format&n=2c_c-XH-dAzVOaDu&q=85&s=230ae34d856b5b3fe8c476c6fe3454c9" alt="" width="2000" height="1000" data-path="images/flask3.png" />

    If you have not done so already, you will be prompted to set up an [SSH key](/core-concepts/security-compliance/authentication/ssh-keys#ssh-keys).
  </Step>

  <Step title="Environment Setup">
    <img src="https://mintcdn.com/aptible/2c_c-XH-dAzVOaDu/images/flask4.png?fit=max&auto=format&n=2c_c-XH-dAzVOaDu&q=85&s=c1644981d2945b756b24845227c23c8a" alt="" width="2000" height="1000" data-path="images/flask4.png" />

    Select your [stack](/core-concepts/architecture/stacks) to deploy your resources. This will determine what region your resources are deployed to. Then, name the [environment](/core-concepts/architecture/environments) your resources will be grouped into.
  </Step>

  <Step title="Prepare the template">
    <img src="https://mintcdn.com/aptible/opX5eNKf32ujRi0n/images/flask5.png?fit=max&auto=format&n=opX5eNKf32ujRi0n&q=85&s=30672f0cb0672b43d9dd556722399f8d" alt="" width="2000" height="1000" data-path="images/flask5.png" />

    Select **Deploy Demo App** for deployment, and follow command-line instructions.
  </Step>

  <Step title="Fill environment variables and deploy">
    <img src="https://mintcdn.com/aptible/opX5eNKf32ujRi0n/images/flask6.png?fit=max&auto=format&n=opX5eNKf32ujRi0n&q=85&s=0d8f624eb8ff7e0914bc352aa9839a37" alt="" width="2000" height="1000" data-path="images/flask6.png" />

    Aptible will automatically fill this template's app configuration, services, and required databases. This includes: a web server, a background worker, a Managed PostgreSQL Database, and a Redis instance. All you have to do is fill the complete the environment variables save and deploy the code!

    Aptible will show you the logs in live time:

    <img src="https://mintcdn.com/aptible/opX5eNKf32ujRi0n/images/flask7.png?fit=max&auto=format&n=opX5eNKf32ujRi0n&q=85&s=a9ba3734bd9f2ef4c7941d088e7e31ea" alt="" width="2000" height="1000" data-path="images/flask7.png" />
  </Step>

  <Step title="Expose your app to the internet">
    <img src="https://mintcdn.com/aptible/opX5eNKf32ujRi0n/images/flask8.png?fit=max&auto=format&n=opX5eNKf32ujRi0n&q=85&s=4c34014ede13d2d1448c0654cd975a1d" alt="" width="2000" height="1000" data-path="images/flask8.png" />

    Now that your code is deployed, it's time to expose your app to the internet. Select the service that needs an [endpoint](/core-concepts/apps/connecting-to-apps/app-endpoints/overview), and Aptible will automatically provision a managed endpoint.
  </Step>

  <Step title="View your deployed app" icon="party-horn">
    <Frame>
      <img src="https://mintcdn.com/aptible/opX5eNKf32ujRi0n/images/flask9.png?fit=max&auto=format&n=opX5eNKf32ujRi0n&q=85&s=541d675b0169b77deef70b1f6ae57ee7" alt="" width="3080" height="1924" data-path="images/flask9.png" />
    </Frame>

    From here, you can optionally test the application's message board and/or "Setup Checklist."
  </Step>
</Steps>

# Continue your journey

<Card title="Deploy custom code" icon="books" iconType="duotone" href="https://www.aptible.com/docs/custom-code-quickstart">
  Read our guide for deploying custom code on Aptible.
</Card>
