Type fixed

This commit is contained in:
TonyJabbour 2021-10-04 15:39:32 +02:00
parent e66b7aa19a
commit dd9cee83db

View file

@ -226,17 +226,17 @@ def get_item(request_dict):
# API as txt # API as txt
def get_item_as_txt(request_dict): def get_item_as_txt(request_dict):
item_id = request_dict.get('id', None)
if not request_dict: if not request_dict:
return {'status': 'error', 'reason': 'Malformed JSON'}, 400 return {'status': 'error', 'reason': 'Malformed JSON'}, 400
item_id = request_dict.get('id', None)
if not item_id: if not item_id:
return {'status': 'error', 'reason': 'Mandatory parameter(s) not provided'}, 400 return {'status': 'error', 'reason': 'Mandatory parameter(s) not provided'}, 400
if not exist_item(item_id): if not exist_item(item_id):
return {'status': 'error', 'reason': 'Item not found'}, 404 return {'status': 'error', 'reason': 'Item not found'}, 404
item_content = get_item_content(item_id) item_content = get_item_content(item_id)
encoded_item_content = item_content.encode("UTF-8") base64_output = base64.b64encode(item_content)
base64_output = base64.b64encode(encoded_item_content)
dict_item = {'id': item_id, 'content': base64_output} dict_item = {'id': item_id, 'content': base64_output}
return dict_item, 200 return dict_item, 200