-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
31 lines (25 loc) · 1.04 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from fastapi import FastAPI, UploadFile, File
from starlette.responses import FileResponse
app = FastAPI()
@app.post("/upload")
async def upload_video(video: UploadFile = File(...)):
# Save the uploaded video
file_path = f"uploaded_videos/{video.filename}"
with open(file_path, "wb") as f:
f.write(await video.read())
# Mirror the video
mirrored_file_path = f"mirrored_videos/mirrored_{video.filename}"
with open(file_path, "rb") as f:
video_data = f.read()
mirrored_video_data = mirror_video(video_data)
with open(mirrored_file_path, "wb") as f:
f.write(mirrored_video_data)
return {"message": "Video uploaded and mirrored successfully!"}
@app.get("/download/{filename}")
async def download_video(filename: str):
file_path = f"mirrored_videos/mirrored_{filename}"
return FileResponse(file_path, media_type="video/mp4", filename=filename)
def mirror_video(video_data):
# Implement your video mirroring logic here
# This is just a placeholder function
return video_data