I created an App Engine application. Till now, I only have a few HTML files to serve. What can I do to make App Engine serve the index.html file whenever someone visits http://example.appengine.com/ ?
Currently, my app.yaml file looks like this:
application: appname
version: 1
runtime: python
api_version: 1
handlers:
- url: /
static_dir: static_files
This should do what you need:
https://gist.github.com/873098
Explanation: In App Engine Python it's possible to use regular expressions as URL handlers in
app.yaml
and redirect all URLs to a hierarchy of static files.Example
app.yaml
:In order to handle requests to URLs that don't end with a recognized type (
.html
,.png
, etc.) or/
you need to redirect those requests toURL + /
so theindex.html
for that directory is served. I don't know of a way to do this inside theapp.yaml
, so I added a javascript redirector. This could also be done with a tiny python handler.redirector.html
: