Deploy Flask to App Engine

Deploy Flask to GCP

Flask
➡️ main.py
App
Engine

Deploy Flask to AppEngine

Kacper Walczak · 19-11-2023

  • Learn how to deploy Flask to AppEngine on Google Cloud Platform.

Introduction

App Engine is a fully managed, serverless platform for developing and hosting web applications at scale.

You can choose from several popular languages, libraries, and frameworks to develop your apps, then let App Engine take care of provisioning servers and scaling your app instances based on demand.

We will focus on Python 3 and Flask framework.

Before you begin

Before you start this tutorial, you need:

  • Google Cloud Platform account,
  • project with enabled billing,
  • enabled Cloud Build API,
  • gcloud command line tool installed on your machine.

Configure App Engine

Visit App Engine

Firstly you need to go to your GCP Console and open App Engine and create an app (if you haven't done it yet).

Select region

I'm located in Poland so I have selected region: europe-central2, choose nearest one to you.

Select service account

Choose default service account and click Next.

Service account is a special account that represents your app rather than an individual user.

That's all with the configuration. Now we can start writing our Flask service.

Write Flask Service

Create files

runtime: python39
 
handlers:
- url: /static
    static_dir: static
 
- url: /.*
    script: auto

Final structure

    • app.yaml
    • main.py
    • requirements.txt
  • Install dependencies

    pip install -r requirements.txt

    Run Flask

    python main.py

    Visit localhost

    http://localhost:5000

    Deploy to App Engine

    Deployment is the simplest step in this tutorial.

    Initialize gcloud

    If you haven't done it yet, you need to initialize gcloud command line tool.

    gcloud init

    Deploy

    This is the final step. Just run the command below and wait for the deployment to finish.

    Deploy is based on the app.yaml file.

    gcloud app deploy

    Visit your app

    gcloud app browse

    That's all! You have successfully deployed your Flask service to App Engine.

    READ

    Latest readings

    • Readings are sites which will help you with detailed

    • information about given topic. Read latest ones from Learn.

    AI

    06-03-2026

    Local Voice Assistant with Ollama
    • Build your own local voice assistant powered by Ollama.

    AI

    06-03-2026

    AI YouTube Thumbnail Generator
    • Generate YouTube thumbnails with FastAPI and Ollama.

    Architecture

    05-09-2024

    Graph DB usage comparison
    • Compare Neo4j and Tigergraph databases, which is easier to work with, etc.