-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
49 lines (37 loc) · 1.31 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
from typing import Union, Annotated
import json
from fastapi import FastAPI, File, UploadFile, BackgroundTasks, Response
import aws_module
import rendering_module
import time
from multiprocessing import Process, Queue
from pydantic import BaseModel
from fastapi.encoders import jsonable_encoder
from fastapi.responses import JSONResponse
class VideoInfo(BaseModel):
item_id : int
video_uuid : str
class ProgInfo(BaseModel):
prog_num : int
elapsed : float
remain : float
app = FastAPI()
@app.get("/api")
def test():
return True
@app.post("/api/downloadvideo")
def download_video(video_info : VideoInfo, backgroundTasks: BackgroundTasks):
aws_module.download_file(video_info.video_uuid, "3d-modeling-mall", video_info.video_uuid)
# sfm_process = Process(target=rendering_module.sfm_runner, args=(video_uuid,))
# sfm_process.start()
# sfm_process.join()
backgroundTasks.add_task(rendering_module.sfm_runner, video_info.video_uuid, video_info.item_id)
@app.get("/api/proginfo")
def get_proginfo():
with open("progress_log/"+"test"+"_progress.json", 'r') as file:
data = json.load(file)
#datas = []
#datas.append(data)
#print(datas)
json_str = json.dumps(data)
return Response(content=json_str, media_type='application/json')