DenisT commited on
Commit
6fa32c7
·
1 Parent(s): 155198f

modified basic and subway

Browse files
Files changed (3) hide show
  1. endpoints/basic.py +6 -0
  2. endpoints/subway.py +5 -0
  3. server.py +7 -0
endpoints/basic.py CHANGED
@@ -21,6 +21,12 @@ async def create_basic_video(
21
  ):
22
  # Save the videos
23
  basic_video_path = "./data/basic/videos/video.mp4"
 
 
 
 
 
 
24
  with open(basic_video_path, "wb") as buffer:
25
  shutil.copyfileobj(video.file, buffer)
26
 
 
21
  ):
22
  # Save the videos
23
  basic_video_path = "./data/basic/videos/video.mp4"
24
+
25
+ # create the directory if it doesn't exist
26
+ if not os.path.exists("./data/basic/videos"):
27
+ os.makedirs("./data/basic/videos")
28
+
29
+ # Save the videos
30
  with open(basic_video_path, "wb") as buffer:
31
  shutil.copyfileobj(video.file, buffer)
32
 
endpoints/subway.py CHANGED
@@ -22,6 +22,11 @@ async def create_subway_video(
22
  ):
23
  top_video_path = "./data/subway/videos/top_video.mp4"
24
  bottom_video_path = "./data/subway/videos/bottom_video.mp4"
 
 
 
 
 
25
  # Save the videos
26
  with open(top_video_path, "wb") as buffer:
27
  shutil.copyfileobj(top_video.file, buffer)
 
22
  ):
23
  top_video_path = "./data/subway/videos/top_video.mp4"
24
  bottom_video_path = "./data/subway/videos/bottom_video.mp4"
25
+
26
+ # Create the directory if it doesn't exist
27
+ if not os.path.exists("./data/subway/videos"):
28
+ os.makedirs("./data/subway/videos")
29
+
30
  # Save the videos
31
  with open(top_video_path, "wb") as buffer:
32
  shutil.copyfileobj(top_video.file, buffer)
server.py CHANGED
@@ -1,6 +1,7 @@
1
  from fastapi import FastAPI
2
  from fastapi.middleware.cors import CORSMiddleware
3
  from fastapi.staticfiles import StaticFiles
 
4
  import uvicorn
5
  from endpoints import subway_router, minecraft_router, basic_router, video_editor
6
 
@@ -17,6 +18,12 @@ app.add_middleware(
17
  # mount static folder
18
  app.mount("/static", StaticFiles(directory="static"), name="static")
19
 
 
 
 
 
 
 
20
  # Include routers
21
  app.include_router(subway_router, prefix="/generate-subtitles")
22
  app.include_router(minecraft_router, prefix="/generate-subtitles")
 
1
  from fastapi import FastAPI
2
  from fastapi.middleware.cors import CORSMiddleware
3
  from fastapi.staticfiles import StaticFiles
4
+ from fastapi.responses import FileResponse
5
  import uvicorn
6
  from endpoints import subway_router, minecraft_router, basic_router, video_editor
7
 
 
18
  # mount static folder
19
  app.mount("/static", StaticFiles(directory="static"), name="static")
20
 
21
+ # Define the root route
22
+ @app.get("/")
23
+ async def root():
24
+ # return the index.html file
25
+ return FileResponse("static/index.html")
26
+
27
  # Include routers
28
  app.include_router(subway_router, prefix="/generate-subtitles")
29
  app.include_router(minecraft_router, prefix="/generate-subtitles")