Sitemap
Geek Culture

A new tech publication by Start it up (https://medium.com/swlh).

Member-only story

Deploy your Flask app on the Google Cloud Platform

3 min readMar 9, 2023

--

Together you are less alone (Photo by Alina Grubnyak)

Assuming you have successfully converted your Python project into a Flask app under localhost.

if __name__ == "__main__":
app.run()

In five simple steps, we will deploy this app (main.py in this example) to the Google Cloud Platform. This will make your Flask app accessible from anywhere in the world over the Internet.

Solution

One approach to deploying the Flask (localhost) app on the Google Cloud Platform (GCP) is to use Google App Engine (GAE).

  1. Create a GCP project: If you don’t already have a GCP account, create one and create a new project.
  2. Set up the Cloud SDK: Install the Cloud SDK on your local machine if you haven’t already.
  3. Set up the app.yaml file: Create an app.yaml file in the root directory of your project. This file is used to configure your GAE environment. Here’s an example:
runtime: python39
entrypoint: gunicorn -b :$PORT main:app

handlers:
- url: /.*
script: auto

This example specifies the Python 3.9 runtime and uses Gunicorn as the server. The entrypoint line specifies the command to start the server. The handlers section…

--

--

Jesko Rehberg
Jesko Rehberg

Written by Jesko Rehberg

Data scientist at https://digitalsalt.com. Views and opinions expressed are entirely my own and may not necessarily reflect those of my company