Beispiel #1
0
    def get(self, mode, days):
        auth_header = request.headers.get('Authorization')
        if auth_header:
            access_token = auth_header.split(" ")[1]
        else:
            return {"message": "This method requires an authorization header."}, 400
        error, client_id = auth_by_token(access_token)

        if error:
            return {"message": error}, 401
        if safe_str_cmp(mode, "now"):
            error_message, response = ThemeController.get_now()
        elif safe_str_cmp(mode, "browse"):
            error_message, response = ThemeController.browse(int(days), client_id)
        else:
            return {"message": "Unsupported mode."}, 400

        if safe_str_cmp(mode, "browse"):
            return {"response": response}

        if error_message:
            return {"message": error_message}, 500


        return {"response": list(map(lambda x: x.json() if x else None, response))}
Beispiel #2
0
 def get(self, mode, index):
     if safe_str_cmp(mode, "now"):
         error_message, response = ThemeController.get_now()
     if safe_str_cmp(mode, "browse"):
         error_message, response = ThemeController.browse(index)
     else:
         return {"message": "Unsupported mode."}, 400
     if error_message:
         return {"message": error_message}, 500
     return {
         "response": list(map(lambda x: x.json() if x else None, response))
     }