|
@@ -23,6 +23,7 @@ import urllib.request
|
|
|
from fastapi.responses import FileResponse
|
|
|
from websocket import create_connection
|
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
+import dataset
|
|
|
#service nginx restart
|
|
|
#uvicorn main:app --host="0.0.0.0" --reload --port 8888
|
|
|
|
|
@@ -117,8 +118,6 @@ async def progress_page():
|
|
|
async def make_anchor_video_v2(req:request2):
|
|
|
x = threading.Thread(target=anchor_video_v2, args=(req.name, req.text_content, req.image_urls))
|
|
|
x.start()
|
|
|
- #return RedirectResponse("https://www.choozmo.com/progress_page")
|
|
|
- #return {"https://www.choozmo.com:8888/progress_page"}
|
|
|
return {"msg":"製作影片需要時間,請您耐心等候 稍後可以在www.choozmo.com:8168/"+req.name+".mp4 中觀看"}
|
|
|
|
|
|
@app.websocket("/progress")
|
|
@@ -131,7 +130,21 @@ async def websocket_endpoint(websocket: WebSocket):
|
|
|
except WebSocketDisconnect:
|
|
|
manager.disconnect(websocket)
|
|
|
|
|
|
-
|
|
|
+@app.get("/history_input")
|
|
|
+async def history_input():
|
|
|
+ db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
+ statement = 'SELECT * FROM history_input ORDER BY timestamp DESC'
|
|
|
+ logs = []
|
|
|
+ for row in db.query(statement):
|
|
|
+ logs.append({'id':row['id'],'name':row['name'],'text_content':row['text_content'],'image_urls':row['image_urls']})
|
|
|
+ return logs
|
|
|
+
|
|
|
+@app.post("/log_test")
|
|
|
+async def log_test(req:request2):
|
|
|
+ db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
+ log_table = db['history_input']
|
|
|
+ pk = log_table.insert({'name':row['name'],'text_content':row['text_content'],'image_urls':row['image_urls']})
|
|
|
+ return pk
|
|
|
|
|
|
def notify_group(msg):
|
|
|
headers = {
|
|
@@ -529,7 +542,6 @@ def anchor_video_v2(name,text_content, image_urls):
|
|
|
sub_img_list[idx][sub_idx].Close()
|
|
|
sub_timer += sub_duration
|
|
|
print(sub_list[idx][sub_idx]['path'])
|
|
|
-
|
|
|
main_timer += clip_duration
|
|
|
idx+=1
|
|
|
|