I'm trying to implement url slugs in my app (python-based). I want the slugged URL to be of the format myhost/<post_id>/<post_title>
When I try to access the page using the above slugged url format, I get an error and (in Chrome, the error says - unexpected token <). If I delete the '/<post_title>' from the url, the page loads correctly. Specifically, I noticed that once I have a 'forward slash' after the <post_id>, I have issues. Everything works fine without that extra slash (extra directory)
My code is
class mainhandler(webapp.RequestHandler):
def get(self):
if (self.request.path == '/test'):
path = os.path.join (os.path.dirname (__file__), 'test.htm')
self.response.headers ['Content-Type'] = 'text/html'
self.response.out.write (template.render (path, {}))
else:
path = os.path.join (os.path.dirname (__file__), 'index.htm')
self.response.headers ['Content-Type'] = 'text/html'
self.response.out.write (template.render (path, {}))
application = webapp.WSGIApplication( [('/.*', mainhandler)], debug=True)
Basically, I want to load the index.htm file and on that file, I have javascript which is supposed to extract the post-id from the URL and do some stuff with it.
Anybody know what I'm doing wrong here?