Deployment of Flask API on GCP App Engine

Updated: Sep 14, 2020


Hi Everyone,  I will explain how to deploy the Flask API code on Google Cloud Platform. I prefer App Engine because:

  • Google creates its own apps using GFS, Big Table and other such technologies, which are available to you when you utilize the Google app engine to create apps. You only must write the code for the app and Google looks after the testing on account of the automatic scaling feature that the app engine has.

Before we deploy our simple app to Google Cloud, we need to login into our account, if you don’t already have one, you can sign up for the GCP Free Tier and get a free $300 credit for trying it out.

We must select the project in the GCP or create a new project.


We must open the Active Cloud Shell to deploy the Flask API using gcloud commands.

Now, we must clone the Flask code from Git repository.

  • git clone https://github.com/GoogleCloudPlatform/python-docs-samples.git

The code structure should contain app.yaml file which has all the configuration that GCP needs such as Python version, libraries, SQL config, environment variables etc

When we deploy to App Engine, we need to enable the Cloud Build API. Here’s the command to do that:

  • gcloud services enable cloudbuild.googleapis.com

Deployment:

  • gcloud app deploy


The app is now running on App Engine. To see it deployed there, you can either navigate to the deployed service URL shown on the console, or type gcloud app browse to launch it in your default browser:

  • gcloud app browse

That’s it, deploying to App Engine Standard is a quick and simple way to run Flask projects on the Google cloud platform. Hope you enjoyed reading this blog. 



Thanks & Regards,

Vinay Kumar MYLAPALLI

Associate Trainee – Enterprise Application Development 

Digital Transformation

w. www.mouritech.com

222 views1 comment

Recent Posts

See All