Webapp2 Handlers¶
Although Ferris is designed for Google Cloud Endpoints, it provides some tooling for webapp2 handlers.
Defining Handlers¶
Similar to endpoint services, handler are defined in the app directory using the convention app/[module]/[module]_handler.py. By following the convention ferris will automatically discover and wire your handlers.
Warning
If you do not follow the conventions then ferris can not automatically discover your handlers. See Discovery for more details.
Inside of your handler file you can define webapp2 handlers as usual:
import webapp2
class HelloHandler(webapp2.RequestHandler):
def get(self):
self.response.write("Hello, world!")
webapp2_routes = [
webapp2.Route('/hello', HelloHandler)
]
Notice the webapp2_routes at the bottom of the file. This is critically important as it tells ferris which routes to use for your handlers.