Add gettext feature (/gettext/<aoid>)

This commit is contained in:
jar3b
2016-03-21 13:08:49 +03:00
parent aa604cc7b7
commit 2b71f7680e
3 changed files with 35 additions and 0 deletions

View File

@@ -21,6 +21,7 @@ class App(BottleCL):
def init_routes(self):
self.add_route(r'/expand/<aoid:re:[\w]{8}(-[\w]{4}){3}-[\w]{12}>', self.__expand)
self.add_route(r'/normalize/<aoid:re:[\w]{8}(-[\w]{4}){3}-[\w]{12}>', self.__normalize)
self.add_route(r'/gettext/<aoid:re:[\w]{8}(-[\w]{4}){3}-[\w]{12}>', self.__gettext)
self.add_route(r'/find/<text>', self.__find)
self.add_route(r'/find/<text>/<strong>', self.__find)
self.add_error(404, self.basic_error_handler)
@@ -45,6 +46,12 @@ class App(BottleCL):
return json.dumps(self._factory.find(text, strong))
def __gettext(self, aoid):
response.content_type = 'application/json'
response.set_header('Access-Control-Allow-Origin', '*')
return json.dumps(self._factory.gettext(aoid))
@staticmethod
def basic_error_handler(error):
response.content_type = 'application/json'