Spaces:
Sleeping
Sleeping
add html files
Browse files- endpoints/basic.py +3 -1
- endpoints/minecraft.py +2 -1
- endpoints/subway.py +2 -1
- endpoints/utils/get_file_name.py +4 -0
- server.py +6 -1
- static/basic.html +35 -0
- static/index.html +18 -0
- static/minecraft.html +37 -0
- static/styles.css +29 -0
- static/subway.html +37 -0
- static/video_cutter.html +29 -0
endpoints/basic.py
CHANGED
@@ -5,6 +5,7 @@ from generate_basic_subtitles import generate_basic_subtitles
|
|
5 |
from endpoints.utils.remove_content_from_dir import remove_content_from_dir
|
6 |
import os
|
7 |
import shutil
|
|
|
8 |
|
9 |
router = APIRouter()
|
10 |
|
@@ -41,4 +42,5 @@ async def create_basic_video(
|
|
41 |
|
42 |
background_tasks.add_task(remove_content_from_dir, "./data/basic/videos")
|
43 |
|
44 |
-
return
|
|
|
|
5 |
from endpoints.utils.remove_content_from_dir import remove_content_from_dir
|
6 |
import os
|
7 |
import shutil
|
8 |
+
from endpoints.utils import get_file_name
|
9 |
|
10 |
router = APIRouter()
|
11 |
|
|
|
42 |
|
43 |
background_tasks.add_task(remove_content_from_dir, "./data/basic/videos")
|
44 |
|
45 |
+
# return the video with the current date and time
|
46 |
+
return FileResponse(result_video_path, media_type="video/mp4", filename=get_file_name("basic"))
|
endpoints/minecraft.py
CHANGED
@@ -5,6 +5,7 @@ from generate_minecraft_subtitles import generate_minecraft_subtitles
|
|
5 |
from endpoints.utils.remove_content_from_dir import remove_content_from_dir
|
6 |
import os
|
7 |
import shutil
|
|
|
8 |
|
9 |
router = APIRouter()
|
10 |
|
@@ -42,4 +43,4 @@ async def create_minecraft_video(
|
|
42 |
|
43 |
background_tasks.add_task(remove_content_from_dir, "./data/minecraft/videos")
|
44 |
|
45 |
-
return FileResponse(result_video_path, media_type="video/mp4", filename="
|
|
|
5 |
from endpoints.utils.remove_content_from_dir import remove_content_from_dir
|
6 |
import os
|
7 |
import shutil
|
8 |
+
from endpoints.utils import get_file_name
|
9 |
|
10 |
router = APIRouter()
|
11 |
|
|
|
43 |
|
44 |
background_tasks.add_task(remove_content_from_dir, "./data/minecraft/videos")
|
45 |
|
46 |
+
return FileResponse(result_video_path, media_type="video/mp4", filename=get_file_name("minecraft"))
|
endpoints/subway.py
CHANGED
@@ -5,6 +5,7 @@ from generate_subway_subtitles import generate_subway_subtitles
|
|
5 |
from endpoints.utils.remove_content_from_dir import remove_content_from_dir
|
6 |
import os
|
7 |
import shutil
|
|
|
8 |
|
9 |
router = APIRouter()
|
10 |
|
@@ -45,4 +46,4 @@ async def create_subway_video(
|
|
45 |
|
46 |
background_tasks.add_task(remove_content_from_dir, "./data/subway/videos")
|
47 |
|
48 |
-
return FileResponse(result_video_path, media_type="video/mp4", filename="
|
|
|
5 |
from endpoints.utils.remove_content_from_dir import remove_content_from_dir
|
6 |
import os
|
7 |
import shutil
|
8 |
+
from endpoints.utils import get_file_name
|
9 |
|
10 |
router = APIRouter()
|
11 |
|
|
|
46 |
|
47 |
background_tasks.add_task(remove_content_from_dir, "./data/subway/videos")
|
48 |
|
49 |
+
return FileResponse(result_video_path, media_type="video/mp4", filename=get_file_name("subway"))
|
endpoints/utils/get_file_name.py
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import time
|
2 |
+
|
3 |
+
def get_file_name(prefix: str) -> str:
|
4 |
+
return f"{prefix}_{time.strftime('%Y%m%d-%H%M%S')}.mp4"
|
server.py
CHANGED
@@ -1,7 +1,8 @@
|
|
1 |
from fastapi import FastAPI
|
2 |
from fastapi.middleware.cors import CORSMiddleware
|
|
|
3 |
import uvicorn
|
4 |
-
from endpoints import subway_router, minecraft_router, basic_router,
|
5 |
|
6 |
app = FastAPI()
|
7 |
|
@@ -13,6 +14,10 @@ app.add_middleware(
|
|
13 |
allow_headers=["*"]
|
14 |
)
|
15 |
|
|
|
|
|
|
|
|
|
16 |
app.include_router(subway_router, prefix="/generate-subtitles")
|
17 |
app.include_router(minecraft_router, prefix="/generate-subtitles")
|
18 |
app.include_router(basic_router, prefix="/generate-subtitles")
|
|
|
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 |
|
7 |
app = FastAPI()
|
8 |
|
|
|
14 |
allow_headers=["*"]
|
15 |
)
|
16 |
|
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")
|
23 |
app.include_router(basic_router, prefix="/generate-subtitles")
|
static/basic.html
ADDED
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8" />
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6 |
+
<title>BASIC</title>
|
7 |
+
</head>
|
8 |
+
<body>
|
9 |
+
<h1>BASIC</h1>
|
10 |
+
<div>
|
11 |
+
<p>What it can do:</p>
|
12 |
+
<p>Provide a basic functionality.</p>
|
13 |
+
</div>
|
14 |
+
<form action="/basic" method="post" enctype="multipart/form-data">
|
15 |
+
<label for="video">Video:</label><br />
|
16 |
+
<input type="file" id="video" name="video" /><br />
|
17 |
+
<label for="color">Color:</label><br />
|
18 |
+
<input type="text" id="color" name="color" /><br />
|
19 |
+
<label for="size">Size:</label><br />
|
20 |
+
<input type="number" id="size" name="size" /><br />
|
21 |
+
<label for="font">Font:</label><br />
|
22 |
+
<input type="text" id="font" name="font" /><br />
|
23 |
+
<label for="credit">Credit:</label><br />
|
24 |
+
<input type="text" id="credit" name="credit" /><br />
|
25 |
+
<label for="credit_size">Credit Size:</label><br />
|
26 |
+
<input
|
27 |
+
type="number"
|
28 |
+
id="credit_size"
|
29 |
+
name="credit_size"
|
30 |
+
/><br /><br />
|
31 |
+
<input type="submit" value="Submit" />
|
32 |
+
</form>
|
33 |
+
<a href="/">Go back to index</a>
|
34 |
+
</body>
|
35 |
+
</html>
|
static/index.html
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8" />
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6 |
+
<title>Home</title>
|
7 |
+
<link rel="stylesheet" href="styles.css" />
|
8 |
+
</head>
|
9 |
+
<body>
|
10 |
+
<h1>BainRotTok</h1>
|
11 |
+
<ul>
|
12 |
+
<li><a href="basic.html">BASIC</a></li>
|
13 |
+
<li><a href="subway.html">SUBWAY</a></li>
|
14 |
+
<li><a href="minecraft.html">MINECRAFT</a></li>
|
15 |
+
<li><a href="video_cutter.html">VIDEO CUTTER</a></li>
|
16 |
+
</ul>
|
17 |
+
</body>
|
18 |
+
</html>
|
static/minecraft.html
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8" />
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6 |
+
<title>MINECRAFT</title>
|
7 |
+
</head>
|
8 |
+
<body>
|
9 |
+
<h1>MINECRAFT</h1>
|
10 |
+
<div>
|
11 |
+
<p>What it can do:</p>
|
12 |
+
<p>Provide minecraft-themed functionality.</p>
|
13 |
+
</div>
|
14 |
+
<form action="/minecraft" method="post" enctype="multipart/form-data">
|
15 |
+
<label for="video">Video:</label><br />
|
16 |
+
<input type="file" id="video" name="video" /><br />
|
17 |
+
<label for="subtitles">Subtitles:</label><br />
|
18 |
+
<input type="text" id="subtitles" name="subtitles" /><br />
|
19 |
+
<label for="color">Color:</label><br />
|
20 |
+
<input type="text" id="color" name="color" /><br />
|
21 |
+
<label for="size">Size:</label><br />
|
22 |
+
<input type="number" id="size" name="size" /><br />
|
23 |
+
<label for="font">Font:</label><br />
|
24 |
+
<input type="text" id="font" name="font" /><br />
|
25 |
+
<label for="credit">Credit:</label><br />
|
26 |
+
<input type="text" id="credit" name="credit" /><br />
|
27 |
+
<label for="credit_size">Credit Size:</label><br />
|
28 |
+
<input
|
29 |
+
type="number"
|
30 |
+
id="credit_size"
|
31 |
+
name="credit_size"
|
32 |
+
/><br /><br />
|
33 |
+
<input type="submit" value="Submit" />
|
34 |
+
</form>
|
35 |
+
<a href="/">Go back to index</a>
|
36 |
+
</body>
|
37 |
+
</html>
|
static/styles.css
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* Add your CSS styles here */
|
2 |
+
|
3 |
+
body {
|
4 |
+
font-family: Arial, sans-serif;
|
5 |
+
margin: 0;
|
6 |
+
padding: 0;
|
7 |
+
}
|
8 |
+
|
9 |
+
h1 {
|
10 |
+
color: #333;
|
11 |
+
}
|
12 |
+
|
13 |
+
ul {
|
14 |
+
list-style-type: none;
|
15 |
+
padding: 0;
|
16 |
+
}
|
17 |
+
|
18 |
+
li {
|
19 |
+
margin-bottom: 10px;
|
20 |
+
}
|
21 |
+
|
22 |
+
a {
|
23 |
+
text-decoration: none;
|
24 |
+
color: #007bff;
|
25 |
+
}
|
26 |
+
|
27 |
+
a:hover {
|
28 |
+
text-decoration: underline;
|
29 |
+
}
|
static/subway.html
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8" />
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6 |
+
<title>SUBWAY</title>
|
7 |
+
</head>
|
8 |
+
<body>
|
9 |
+
<h1>SUBWAY</h1>
|
10 |
+
<div>
|
11 |
+
<p>What it can do:</p>
|
12 |
+
<p>Provide subway-themed functionality.</p>
|
13 |
+
</div>
|
14 |
+
<form action="/subway" method="post" enctype="multipart/form-data">
|
15 |
+
<label for="top_video">Top Video:</label><br />
|
16 |
+
<input type="file" id="top_video" name="top_video" /><br />
|
17 |
+
<label for="bottom_video">Bottom Video:</label><br />
|
18 |
+
<input type="file" id="bottom_video" name="bottom_video" /><br />
|
19 |
+
<label for="color">Color:</label><br />
|
20 |
+
<input type="text" id="color" name="color" /><br />
|
21 |
+
<label for="size">Size:</label><br />
|
22 |
+
<input type="number" id="size" name="size" /><br />
|
23 |
+
<label for="font">Font:</label><br />
|
24 |
+
<input type="text" id="font" name="font" /><br />
|
25 |
+
<label for="credit">Credit:</label><br />
|
26 |
+
<input type="text" id="credit" name="credit" /><br />
|
27 |
+
<label for="credit_size">Credit Size:</label><br />
|
28 |
+
<input
|
29 |
+
type="number"
|
30 |
+
id="credit_size"
|
31 |
+
name="credit_size"
|
32 |
+
/><br /><br />
|
33 |
+
<input type="submit" value="Submit" />
|
34 |
+
</form>
|
35 |
+
<a href="/">Go back to index</a>
|
36 |
+
</body>
|
37 |
+
</html>
|
static/video_cutter.html
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8" />
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
6 |
+
<title>VIDEO CUTTER</title>
|
7 |
+
</head>
|
8 |
+
<body>
|
9 |
+
<h1>VIDEO CUTTER</h1>
|
10 |
+
<div>
|
11 |
+
<p>What it can do:</p>
|
12 |
+
<p>Provide video cutting functionality.</p>
|
13 |
+
</div>
|
14 |
+
<form
|
15 |
+
action="/video_cutter"
|
16 |
+
method="post"
|
17 |
+
enctype="multipart/form-data"
|
18 |
+
>
|
19 |
+
<label for="video">Video:</label><br />
|
20 |
+
<input type="file" id="video" name="video" /><br />
|
21 |
+
<label for="start_time">Start Time:</label><br />
|
22 |
+
<input type="text" id="start_time" name="start_time" /><br />
|
23 |
+
<label for="end_time">End Time:</label><br />
|
24 |
+
<input type="text" id="end_time" name="end_time" /><br /><br />
|
25 |
+
<input type="submit" value="Submit" />
|
26 |
+
</form>
|
27 |
+
<a href="/">Go back to index</a>
|
28 |
+
</body>
|
29 |
+
</html>
|