REGION_ID is an abbreviated code that Google assigns
based on the region you select when you create your app. The code does not
correspond to a country or province, even though some region IDs may appear
similar to commonly used country and province codes. Including
REGION_ID.r in App Engine URLs is optional for
existing apps and will soon be required for all new apps.
To ensure a smooth transition, we are slowly updating App Engine to use region IDs. If we haven't updated your Google Cloud project yet, you won't see a region ID for your app. Since the ID is optional for existing apps, you don't need to update URLs or make other changes once the region ID is available for your existing apps.
Learn more about region IDs.
Sites hosted on App Engine are hosted on the
REGION_ID.r.appspot.com subdomain, such
[my-project-id].uc.r.appspot.com. After you deploy your site, you can map
your own domain name to your App Engine-hosted website.
Before you begin
Before you can host your website on Google App Engine:
Create a new Cloud Console project or retrieve the project ID of an existing project to use:
Tip: You can retrieve a list of your existing project IDs with the gcloud command line tool.
Install and then initialize the Google Cloud SDK:
Listing your Cloud Console project IDs
From the command line, run:
gcloud projects list
Creating a website to host on Google App Engine
Basic structure for the project
This guide uses the following structure for the project:
app.yaml: Configure the settings of your App Engine application.
css/: Directory to store stylesheets.
style.css: Basic stylesheet that formats the look and feel of your site.
images/: Optional directory to store images.
index.html: An HTML file that displays content for your website.
- Other asset directories.
app.yaml file is a configuration file that tells App Engine how to map
URLs to your static files. In the following steps, you will add handlers that
www/index.html when someone visits your website, and all static
files will be stored in and called from the
app.yaml file in your application's root directory:
- Create a directory that has the same name as your project ID. You can find your project ID in the Console.
- In directory that you just created, create a file named
app.yamlfile and add the following code to the file:
runtime: python27 api_version: 1 threadsafe: true handlers: - url: / static_files: www/index.html upload: www/index.html - url: /(.*) static_files: www/\1 upload: www/(.*)
More reference information about the
app.yaml file can be found in the
Create an HTML file that will be served when someone navigates to the root page
of your website. Store this file in your
<html> <head> <title>Hello, world!</title> <link rel="stylesheet" type="text/css" href="/css/style.css"> </head> <body> <h1>Hello, world!</h1> <p> This is a simple static HTML file that will be served from Google App Engine. </p> </body> </html>
Deploying your application to App Engine
When you deploy your application files, your website will be uploaded to App
Engine. To deploy your app, run the following command from within the root
directory of your application where the
app.yaml file is located:
gcloud app deploy
- Include the
--projectflag to specify an alternate Cloud Console project ID to what you initialized as the default in the
- Include the
-vflag to specify a version ID, otherwise one is generated for you. Example:
To learn more about deploying your app from the command line, see Deploying a Python 2 App.
Viewing your application
To launch your browser and view the app at
https://PROJECT_ID.REGION_ID.r.appspot.com, run the following command:
gcloud app browse