marquesafonso commited on
Commit
23e5406
·
1 Parent(s): 8530b58

separate html to static folder. added read_html util.

Browse files
Files changed (2) hide show
  1. main.py +3 -15
  2. utils/read_html.py +4 -0
main.py CHANGED
@@ -5,6 +5,7 @@ from typing import Optional
5
  from utils.process_video import process_video
6
  from utils.zip_response import zip_response
7
  from utils.api_configs import api_configs
 
8
  import shutil, os, logging, uvicorn, secrets
9
 
10
  app = FastAPI()
@@ -34,21 +35,8 @@ async def root():
34
 
35
  @app.get("/submit_video/")
36
  async def get_form():
37
- html_content = """
38
- <html>
39
- <body>
40
- <form action="/process_video/" enctype="multipart/form-data" method="post">
41
- Video File: <input type="file" name="video_file"><br>
42
- Subtitles File: <input type="file" name="srt_file"><br>
43
- Max words per line: <input type="number" name="max_words_per_line" value="8"><br>
44
- Font size: <input type="number" name="fontsize" value="36"><br>
45
- Font: <input type="text" name="font" value="FuturaPTHeavy"><br>
46
- Background color: <input type="text" name="bg_color" value="#070a13b3"><br>
47
- Text color: <input type="text" name="text_color" value="white"><br>
48
- <input type="submit">
49
- </form>
50
- </body>
51
- </html>
52
  """
53
  return HTMLResponse(content=html_content)
54
 
 
5
  from utils.process_video import process_video
6
  from utils.zip_response import zip_response
7
  from utils.api_configs import api_configs
8
+ from utils.read_html import read_html
9
  import shutil, os, logging, uvicorn, secrets
10
 
11
  app = FastAPI()
 
35
 
36
  @app.get("/submit_video/")
37
  async def get_form():
38
+ html_content = f"""
39
+ {read_html(os.path.join(os.getcwd(),"static/submit_video.html"))}
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  """
41
  return HTMLResponse(content=html_content)
42
 
utils/read_html.py ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ def read_html(html_file):
2
+ with open(html_file, 'r', encoding='utf-8') as f:
3
+ content = f.read()
4
+ return content