def get_tile(request, tile_key): """ Return Json from redis for tile_key """ if not checkAccessToken(method='GET', request=request, unsecured=True): return HttpResponse('API KEY incorrect', status=401) redis = MyCache().redis if redis.exists(getRedisPrefix(tile_key)): return HttpResponse(redis.get(tile_key)) return HttpResponseBadRequest(f'{tile_key} key does not exist.')
def delete_tile(request, tile_key): """ Delete in redis """ if not checkAccessToken(method='DELETE', request=request, unsecured=True): return HttpResponse('API KEY incorrect', status=401) redis = MyCache().redis if redis.exists(getRedisPrefix(tile_key)): redis.delete(tile_key) return HttpResponse('Tile\'s data deleted.') return HttpResponseBadRequest(f'{tile_key} key does not exist.')
def get_tile(request, tile_key): httpMessage = '' httpStatus_code = 200 redis = MyCache().redis if redis.exists(getRedisPrefix(tile_key)): if request.method == 'DELETE': redis.delete(tile_key) httpMessage = 'Tile\'s data deleted.' if request.method == 'GET': httpMessage = redis.get(tile_key) else: httpMessage = f'{tile_key} key does not exist.' httpStatus_code = 400 return httpMessage, httpStatus_code