Skip to content

Commit

Permalink
updated put_like.py and fixed get_meme.py
Browse files Browse the repository at this point in the history
  • Loading branch information
John-J-Riehl committed Aug 14, 2022
1 parent 390fe25 commit da78eec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions back-end/get_meme.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ def lambda_handler(event, context):

# create an in-memory file
with io.BytesIO() as in_mem_file:
### download the image data into the in-memory file. return
### an error code if the object doesn't exist
### download the image data into the in-memory
### file. return error code if it doesn't exist

# load the meme as an image to get its type
image = Image.open(in_mem_file)

time_now = int(time.time())

### build the object to return
meme_data = {
return_data = {
"imageUrl": (f"data:image/{image.format};base64,"
+ base64.b64encode(in_mem_file.getvalue()).decode("utf-8")),
}

### return success code and meme_data
### return success code and return_data
14 changes: 7 additions & 7 deletions back-end/put_like.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import time

def lambda_handler(event, context):
# get the meme_id, event_body, and user_name
### get the meme_id and user_name

# verify the meme is in the database
### query the database for the meme's info. return 404 error if it's not in the database.

# find out whether this user has liked this meme already
### return 400 error if the meme was already liked by this user or if this user posted the meme

# add the like to im-likes
# add to the item's timeToDie
### build an update expression to add the like and increment timeToDie by one hour

### update the item

# return success
### return 201 success

0 comments on commit da78eec

Please sign in to comment.