Google webapp to receive feedbacks
This commit is contained in:
23
feedback-ltworf/micro_webapp2.py
Normal file
23
feedback-ltworf/micro_webapp2.py
Normal file
@@ -0,0 +1,23 @@
|
||||
import webapp2
|
||||
|
||||
class WSGIApplication(webapp2.WSGIApplication):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(WSGIApplication, self).__init__(*args, **kwargs)
|
||||
self.router.set_dispatcher(self.__class__.custom_dispatcher)
|
||||
|
||||
@staticmethod
|
||||
def custom_dispatcher(router, request, response):
|
||||
rv = router.default_dispatcher(request, response)
|
||||
if isinstance(rv, basestring):
|
||||
rv = webapp2.Response(rv)
|
||||
elif isinstance(rv, tuple):
|
||||
rv = webapp2.Response(*rv)
|
||||
|
||||
return rv
|
||||
|
||||
def route(self, *args, **kwargs):
|
||||
def wrapper(func):
|
||||
self.router.add(webapp2.Route(handler=func, *args, **kwargs))
|
||||
return func
|
||||
|
||||
return wrapper
|
Reference in New Issue
Block a user