Deploying to Google App Engine
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
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.
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: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: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.
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.
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.
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.
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.
Become a Member to join the conversation.