Skip to content

Commit

Permalink
Added HTTPException if content type is not MP4 or MOV
Browse files Browse the repository at this point in the history
  • Loading branch information
andriawang6 committed Feb 11, 2024
1 parent 2fb0a70 commit c5a5e7e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 2 additions & 2 deletions backend/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import json
import logging
import os
Expand Down Expand Up @@ -129,6 +128,8 @@ async def upload(req: Request, exercise: int):
extension = ".mp4"
if req.headers.get('content-type') == "video/quicktime":
extension = ".mov"
else:
raise HTTPException(status_code=400, detail="Content type must be video/mp4 or video/quicktime")

get_running_loop().run_in_executor(None, lambda: analyze(id, exercise, extension, video_bytes))

Expand Down Expand Up @@ -160,7 +161,6 @@ async def event_generator():
return

result_video_file = result["video_file"]
print(result_video_file.name)
videos[id] = result_video_file
del result["video_file"]

Expand Down
8 changes: 7 additions & 1 deletion src/AppPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,13 @@ export const AppPage = () => {

sse.current.addEventListener('error', () => {
notifications.show({
message: 'Failed to open SSE connection.',
icon: (
<IconX style={{ width: rem(18), height: rem(18) }} />
),
color: 'red',
title: 'Error',
autoClose: 10_000,
message: 'Error during SSE connection.',
});
sse.current?.close();
sse.current = undefined;
Expand Down

0 comments on commit c5a5e7e

Please sign in to comment.