Skip to content

Commit

Permalink
Merge pull request #35 from CornellDataScience/video
Browse files Browse the repository at this point in the history
Add a backend call for the videos to be displayed on the frontend
  • Loading branch information
Mikonooooo authored Dec 2, 2023
2 parents 4de3d20 + 85c0f42 commit 213d621
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
17 changes: 16 additions & 1 deletion src/api/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
import os
import subprocess
from dotenv import load_dotenv
from format import Format

import sys
import os

from ..format import Format



# Amazon S3 Connection
load_dotenv()
Expand Down Expand Up @@ -82,3 +88,12 @@ async def get_formatted_results():
except Exception as e:
raise HTTPException(status_code=500, detail=str(e))


@app.get("/video")
async def get_videos():
file_path = 'tmp/minimap.mp4'
def iterfile():
with open(file_path, mode="rb") as file_like:
yield from file_like

return StreamingResponse(iterfile(), media_type="video/mp4")
2 changes: 1 addition & 1 deletion src/format.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# results_formatter.py
import json
from state import GameState # Assuming GameState class is in state.py
from .state import GameState # Assuming GameState class is in state.py
class Format:
def results():
return format_results_for_api(GameState)
Expand Down
11 changes: 11 additions & 0 deletions src/view/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,19 @@ def results_page():
# Results
These are the results. Here's the processed video and a minimap of the player positions.
"""

)
# st.video(open(st.session_state.processed_video, "rb").read())
#here we need to add the call for the videos


response = requests.get(SERVER_URL + "video")
if response.status_code == 200:
video_bytes = response.content() # Returns the formatted results as JSON
video_bytes = response
st.video(video_bytes)
else:
st.header ("error- Failed to retrieve data from the backend.")


st.markdown("## Statistics")
Expand Down

0 comments on commit 213d621

Please sign in to comment.