I'm using Google App Engine with Python environment.
I have my main code in the main.py file. I want to create a new .py file for a different page. I created the .py file, added the path to the yaml file. But I still get a '404 Error, resource not found'.
Here is my yaml file
application: myapp version: 1 runtime: python27 api_version: 1 threadsafe: yes handlers: - url: .* script: main.app - url: /hello script: hello.app libraries: - name: webapp2 version: "2.5.2"
When the user goes to exampleurl.com/hello I want the hello.py file to be executed.
Here's the current content of hello.py
import webapp2 class HeyPage(webapp2.RequestHandler): def get(self): self.response.headers['Content-Type'] = 'text/html' self.response.out.write('Hello, All!') app = webapp2.WSGIApplication([('/hello', HeyPage)], debug=True)
Here is the log:
INFO 2014-01-10 06:15:31,150 module.py:617] default: "GET /hello HTTP/1.1" 404 154
You should list your handlers from most specific to least specific. Your handler:
- url: .* script: main.app
basically says that
should handle every url. Since it is the first in the list,
will try to handle every request regardless of the handlers that follow it in
. Change it to:
handlers: - url: /hello script: hello.app - url: .* script: main.app
And all should work.