Deploying to Google App Engine
00:00 Deploying to Google App Engine.
00:04 It’s finally time to bring your app online. But first, your code needs a place to live on Google’s servers, and you need to make sure that it gets there safely.
In this section of the course, you’ll work on completing the necessary deployment setups both in the cloud and locally. Follow this process step-by-step. You can compare what you see on the screen with what you see in your browser. The project name used in this course is
00:32 Start by signing in to the Google Cloud Platform. Navigate to the dashboard view, where you’ll see a toolbar at the top of the window, as seen on-screen.
00:42 Select the downward-facing arrow button towards the left side of the toolbar. This will pop up a modal containing a list of your current Google projects.
00:50 The list may be empty if you haven’t created any projects yet. On the top right of that modal, find the NEW PROJECT button and click it.
01:01 Clicking NEW PROJECT will redirect you to a new page where you can decide on a name for your project. This name will appear in the URL of your application, which will look similar to the one seen on-screen at the moment.
hello-app as the name for this project to stay consistent with the course.
01:22 You can see your project ID below the Project name input field. The project ID consists of the name you entered and a number that Google App Engine adds. Copy your personal project ID since you’ll need it later on for deploying. Note that as the project ID needs to be unique, your number will be different than the one shown in this course.
01:44 Next, click CREATE and wait for the project to be set up on Google App Engine’s side. Once that’s done, a notification will pop up telling you that a new project has been created.
01:55 It also gives you the option to select it. Go ahead and do that by clicking SELECT PROJECT. This will redirect you to the main page of your new Google Cloud Platform project. It should look similar to what you see on-screen.
02:10 From here, you want to switch to the dashboard of Google App Engine. You can do that by clicking the hamburger menu on the top left.
02:21 Next, scroll down to select App Engine in the first list. Note that you may need to expand to see all products. It’s located under SERVERLESS.
02:37 Now, select Dashboard in the next pop-up list.
02:44 This will redirect you to the App Engine dashboard of your new project. Since the project is empty so far, the page will look similar to what’s seen on-screen. When you get to this page, it means you’ve completed setting up a new project on Google App Engine.
02:59 You’re now ready to head back to the terminal on your computer and complete the local steps necessary to deploy your app to this project.
After successfully installing the Google Cloud SDK, you have access to the
gcloud command-line interface. This program comes with helpful instructions that guide you through deploying your web app. You may have noticed on the Google App Engine website that there was a suggested command,
gcloud app deploy. Open up your terminal, navigate to your project folder, and then try running that command.
03:33 When you execute this command without any previous setup, the program will respond with an error message.
03:43 You received this error message because you can’t deploy any code to your Google App Engine account unless you prove to Google that you’re the owner of that account.
You’ll need to authenticate with your Google App Engine account from your local computer. The error message provided you with the command you need to run,
gcloud auth login. So type that into the terminal now.
04:07 This will start the authentication process by generating a validation URL and opening it up in your browser. Complete the process by selecting the appropriate Google account in the browser window and granting Google Cloud SDK the necessary privileges. After you do this, you can return to your terminal, where you’ll see some information about the authentication process. If you see this message, then the authentication was successful.
You can also see the command-line program again offers you helpful information about your next step. It tells you there’s currently no project set and that you can set one by running
gcloud config set project with a project ID.
04:47 Now you’ll need the project ID that you noted earlier. Note that you can always get your project ID by heading to the Google App Engine website and clicking the downward-facing arrow that brings up the modal showing all your Google projects.
05:01 The project ID is listed to the right of your project’s name and usually consists of the project name and a six-digit number. Be sure to replace the project name seen on-screen with your own project ID when running the suggested command.
05:25 Your terminal willl print out a short feedback message that the project property has been updated. After successfully authenticating and setting the project to your project ID, you’ve completed the necessary setup steps.
05:38 Now you’re ready to try the initial deployment command a second time.
gcloud app fetches your authentication credentials as well as the project ID information from the default configuration you just set up, and this allows you to proceed. Next, you need to select the region where your application should be hosted. Enter one of the numbers that are listed on the left-hand side and press Enter.
06:05 Note that it doesn’t really matter which region you choose for this particular app. But if you’re building a large application that gets a significant amount of traffic, then you want to deploy it to a server that’s physically close to where most of your users are. After you enter a number, the CLI will continue with the setup process. Before deploying your code to Google App Engine, it’ll show you an overview of what the deployment will look like and ask you for a final confirmation.
After you confirm the setup by typing
Y, your deployment will finally be on its way. The terminal will show you some more information and a small loading animation while Google App Engine sets up your project on its servers.
06:46 As this is the first deployment of your web app, it may take a few minutes to complete. Once the deployment is finished, you’ll see another helpful output in the console, which will look similar to the one seen on-screen. Note that you may be asked to provide a payment option during this process.
07:02 You won’t be charged providing you stay within the limits mentioned in the course, but you will need to provide a valid payment method to complete the deployment.
You can now navigate to the mentioned URL in your browser, or you can type the suggested command,
gcloud app browse, to access your live web app.
You should see the same short text response that you saw earlier when you ran the app on your localhost:
Congratulations, it's a web app! Notice that this website has a URL that you can share with other people, and they’ll be able to access it.
07:36 You now have a live Python web application! With this, you’ve completed the necessary steps to get your local Python code up on the web. However, the only functionality that you’ve put up online so far is printing out a string of text. So it’s time to step your game up a bit.
07:54 In the next sections, you’ll bring more interesting functionality online. You’ll refactor the code of a local temperature converter script into a Flask web app.
Hi. I think you may be a bit confused - Google App Engine isn’t put into the virtual environment, but you use the
gcloud command line tool to deploy your app to GAE. You need to install the gcloud CLI tool - cloud.google.com/sdk/docs/install - and then following along with this video you should be able to create a new project in GAE and then deploy it.
Become a Member to join the conversation.
Mihaela Costea on Oct. 29, 2022
The course jumps from local testing of the website to deploying the app with gcloud engine via virtual environment....QHEN and HOW do we het the googdle cloud engine into the virtual environment? these steps areb missing. Please provide appropriate instructions.