Skip to content

Commit

Permalink
final starting code update
Browse files Browse the repository at this point in the history
  • Loading branch information
John-J-Riehl committed Aug 21, 2022
1 parent da78eec commit 848ae91
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 20 deletions.
14 changes: 0 additions & 14 deletions back-end/delete_meme.py

This file was deleted.

1 change: 1 addition & 0 deletions back-end/post_meme.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def lambda_handler(event, context):
bucket = ### get the sub-resource

# save it in an in-memory file-like object
# if you're unfamiliar with the "with" statement, read this: https://www.geeksforgeeks.org/with-statement-in-python/
with io.BytesIO() as in_mem_file:
image.save(in_mem_file, format=image.format)
in_mem_file.seek(0)
Expand Down
42 changes: 36 additions & 6 deletions client/src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ const App = () => {
if (typeof error.json === "function") {
error.json()
.then((jsonError) => {
alert(`The server is alive, but reports this error: ${jsonError}`);
if (typeof jsonError === "string") {
alert(`The server is alive, but reports this error: ${jsonError}`);
} else if (jsonError.hasOwnProperty("message")) {
alert(`The server is alive, but reports this error: ${jsonError.message}`);
} else {
alert("The server is alive but reports an error.")
}
})
.catch(() => {
alert(`The server is not alive. I received this error: ${error.statusText ?? error}`);
Expand Down Expand Up @@ -108,7 +114,13 @@ const App = () => {
if (typeof error.json === "function") {
error.json()
.then((jsonError) => {
alert(`The server is alive, but reports this error: ${jsonError}`);
if (typeof jsonError === "string") {
alert(`The server is alive, but reports this error: ${jsonError}`);
} else if (jsonError.hasOwnProperty("message")) {
alert(`The server is alive, but reports this error: ${jsonError.message}`);
} else {
alert("The server is alive but reports an error.")
}
})
.catch(() => {
alert(`The server is not alive. I received this error: ${error.statusText ?? error}`);
Expand Down Expand Up @@ -202,7 +214,13 @@ const App = () => {
if (typeof error.json === "function") {
error.json()
.then((jsonError) => {
alert(`The server couldn't post the meme due to this error: ${jsonError}`);
if (typeof jsonError === "string") {
alert(`The server is alive, but reports this error: ${jsonError}`);
} else if (jsonError.hasOwnProperty("message")) {
alert(`The server is alive, but reports this error: ${jsonError.message}`);
} else {
alert("The server is alive but reports an error.")
}
})
.catch(() => {
alert(`The server is not alive. I received this error: ${error.statusText ?? error}`);
Expand Down Expand Up @@ -234,7 +252,13 @@ const App = () => {
if (typeof error.json === "function") {
error.json()
.then((jsonError) => {
alert(`The server couldn't retrieve the meme due to this error: ${jsonError}`);
if (typeof jsonError === "string") {
alert(`The server is alive, but reports this error: ${jsonError}`);
} else if (jsonError.hasOwnProperty("message")) {
alert(`The server is alive, but reports this error: ${jsonError.message}`);
} else {
alert("The server is alive but reports an error.")
}
})
.catch((nonsonError) => {
alert(`The server is not alive. I received this error: ${error.statusText ?? error}`);
Expand Down Expand Up @@ -266,8 +290,14 @@ const App = () => {
if (typeof error.json === "function") {
error.json()
.then((jsonError) => {
alert(`The server couldn't retrieve the meme due to this error: ${jsonError}`);
})
if (typeof jsonError === "string") {
alert(`The server is alive, but reports this error: ${jsonError}`);
} else if (jsonError.hasOwnProperty("message")) {
alert(`The server is alive, but reports this error: ${jsonError.message}`);
} else {
alert("The server is alive but reports an error.")
}
})
.catch(() => {
alert(`The server is not alive. I received this error: ${error.statusText ?? error}`);
});
Expand Down

0 comments on commit 848ae91

Please sign in to comment.