Deploy Flask to GCP
➡️ main.py
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,
-
projectwith enabled billing, - enabled
Cloud BuildAPI, -
gcloudcommand 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: autoFinal structure
- app.yaml
- main.py
- requirements.txt
Install dependencies
pip install -r requirements.txtRun Flask
python main.pyVisit localhost
http://localhost:5000Deploy 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 initDeploy
This is the final step. Just run the command below and wait for the deployment to finish.
Deploy is based on the
app.yamlfile.
gcloud app deployVisit your app
gcloud app browseThat'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.
06-03-2026
Build your own local voice assistant powered by Ollama.
06-03-2026
Generate YouTube thumbnails with FastAPI and Ollama.
05-09-2024
Compare Neo4j and Tigergraph databases, which is easier to work with, etc.