How to get handler class based on the URL in a handler itself?

32 views
Skip to first unread message

Ralph Zajac

unread,
Apr 2, 2013, 6:29:17 AM4/2/13
to web...@googlegroups.com
Hey,

So I have single page application where all the routing is done in JavaScript (AngularJS). From the server I return only partial HTMLs as needed.

Now I'd like to make sure Google can index my application using _escaped_fragment_. Lets say I have following URL in my application:

http://example.com/user/profile/a

It would become:http://example.com/?_escaped_fragment_=user/profile/a

When Google is indexing my page.

That means that all requests would go through my IndexHandler that has to decide what to do with it.

Inside IndexHandler I'd like to somehow get the class that handless '/user/profile/a' so I can call special method on it that returns full HTML for a page (not partial).

Code would look something like this: 

class IndexHandler(webapp2.RequestHandler): 
  def get(self): 
    # In my example this would return 
    'user/profile/a' fragment = self.request.GET.get('_escaped_fragment_', '') 

    if fragment: 
      fragment = '/' + fragment 

      # This is something I have no idea how to do 
      clas_Im_looking_for = XXXX(fragment).get_handler() 

      response = webapp2.Response() 
      handler = clas_Im_looking_for(request, response) 

     # Fragment get is my method 
     response = handler.fragment_get()


I appreciate any suggestions, Thanks!

Ignacio Fiorentino

unread,
Apr 7, 2013, 5:43:43 PM4/7/13
to web...@googlegroups.com
Hi Ralph, I answered you in the GAE Python community on G+. Link to post
Reply all
Reply to author
Forward
0 new messages