Unlike a traditional web hosting environment, Google App Engine does not serve files directly out of your application's source directory unless configured to do so. We named our template file
index.html, but this does not automatically make the file available at the URL
Using Static Files
guestbook/app.yaml and replace its contents with the following:
handlers section defines two handlers for URLs. When App Engine receives a request with a URL beginning with
/stylesheets, it maps the remainder of the path to files in the
stylesheets directory and, if an appropriate file is found, the contents of the file are returned to the client. All other URLs match the
/ path, and are handled by the
application object in the
By default, App Engine serves static files using a MIME type based on the filename extension. For example, a file with a name ending in
.css will be served with a MIME type of
text/css. You can configure explicit MIME types by using the
mime_type setting when configuring your handlers in
URL handler path patterns are tested in the order they appear in
app.yaml, from top to bottom. In this case, the
/stylesheets pattern will match before the
/.* pattern will for the appropriate paths. For more information on URL mapping and other options you can specify in
app.yaml, see the app.yaml reference.
Note: You can specify
settings in the static directory handler to supply custom headers in the responses
returned by the handler. This is useful, for example, for including the
`Access-Control-Allow-Origin` header required to support CORS. For more
information, see the documentation for
Static file handlers.
Create the directory
guestbook/stylesheets/. In this new directory, create a new file named
main.css with the following contents:
guestbook/index.html and insert the following lines between the
<body> tags at the top:
Reload the page in your browser. The new version uses the stylesheet.
The time has come to reveal your finished application to the world.