Below is the code of my app.yaml file. If I go to localhost:8080/ my index.app loads correctly. If I go to localhost:8080/index.html I get a 404 error. If I go to any other page for example localhost:8080/xxxx the not_found.app loads correctly. Why am I getting a 404 Error for the /index\.html case?
Thanks!
application: myapp
version: 1
runtime: python27
api_version: 1
threadsafe: true
handlers:
- url: /index\.html
script: index.app
- url: /
script: index.app
- url: /assets
static_dir: assets
- url: /*
script: not_found.app
libraries:
- name: jinja2
version: latest
Code from index.py
class MainPage(webapp2.RequestHandler):
def get(self):
template = jinja_environment.get_template(‘index.html’)
self.response.out.write(template.render(template_values))
app = webapp2.WSGIApplication([(‘/’, MainPage)],
debug=True)
The fix was located in the bolded text!
It looks like your
appvariable inindexdoes not have a handler forindex.html. For instance:If your application gets routed to
index, it will look through the handlers defined and try to find a match to/index.html. In this example, if you go to/, it will work fine since that handler is defined; however if you go toindex.html, GAE doesn’t know which class to call, and it therefore returns a 404. As a simple test, trySince this is ostensibly a handler for anyone typing
index.htmlor any other permutation ofindex., you could use something like this to capture a broader array of cases (because internally, you can just route using/if you need to):