Skip to content

Commit

Permalink
Testing Backend
Browse files Browse the repository at this point in the history
  • Loading branch information
dweizzz committed Dec 2, 2023
1 parent 68e531b commit 5ee9e82
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/view/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,38 @@ def process_video(video_file):
return False
return True

def upload(video_file):
user_video: str = st.session_state.user_file
if video_file is None:
print("No video")
else:
r = requests.post(
SERVER_URL + "upload", files={"video_file": video_file}, timeout=120
)
if r.status_code == 200:
print("Successfully uploaded file")
data = r.json()
print(data)
st.session_state.upload_name = data.get("message")
with open(user_video, "wb") as f: # TODO is local write; temp fix
f.write(video_file.getvalue())
else:
print("Error uploading file") # TODO make an error handler in frontend
return False
st.session_state.is_downloaded = False

def health_check():
r = requests.get(
SERVER_URL, timeout=120
)
if r.status_code == 200:
print("Successfully got file")
data = r.json()
print(data.get("message"))
else:
print("Error getting file") # TODO make an error handler in frontend
return False
st.session_state.is_downloaded = False

# Pages
def main_page():
Expand Down Expand Up @@ -107,7 +139,7 @@ def loading_page():
"",
hc.Loaders.pulse_bars,
):
finished = process_video(video_file=st.session_state.video_file)
finished = upload(video_file=st.session_state.video_file)
if finished:
state = 2
else:
Expand Down

0 comments on commit 5ee9e82

Please sign in to comment.