Question

I recently had major troubles with Google App Engine and Python as I am inexperienced, so, by luck I found GAE Boilerplate on GitHub. I started using it, and everything's fine, but I want to add another template about.html. How would I do that? I tried creating an HTML document in boilerplate/templates/about.html, and then linking to that document from the homepage via:

  • a href: /about/
  • a href: /about.html
  • a href: /about
  • a href: http://fullurl.com/about.html

But none of these seem to work. Is there a python script that acts as a handler for these types of things that I have to manually edit? I tried googling, but not much help is found for GAE boilerplate on the net, just a few docs and readmes which don't really go into much detail.

I am new to launching websites, GAE and Python script, so forgive me if this is a stupid question. Any help would be much appreciated!

Was it helpful?

Solution

You need to route a path to /about/. From the looks of it, you have to edit the file boilerplate/routes.py.

(disclaimer: I've never used GAE Boilerplate)

First, set up the route to /about/ by adding this line to the end of the routes.py file:

_routes.append(RedirectRoute('/about/', handlers.AboutRequestHandler, name='about'))

But you also need a controller that will dictate how the about.html view is displayed. Add the following code to the boilerplate/handlers.py file:

class AboutRequestHandler(BaseHandler):
    """
    Handler to show the about page
    """

    def get(self):
        """ Returns a simple HTML form for about."""
        return self.render_template('about.html')

If your about.html file is put in the boilerplate/templates folder, this should work. I haven't tested this so I can't be sure, but you now have a route and a controller.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top