ming преди 3 години
родител
ревизия
b2c81716b1
променени са 2 файла, в които са добавени 27 реда и са изтрити 33 реда
  1. 14 16
      index2.html
  2. 13 17
      main.py

+ 14 - 16
index2.html

@@ -101,27 +101,25 @@
     </form>
         
     
-
-
-
-
-<script>
-function openNav() {
-  document.getElementById("mySidenav").style.width = "250px";
-}
-
-function closeNav() {
-  document.getElementById("mySidenav").style.width = "0";
-}
-</script>
-
-
   </div>
   
   <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
   <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js'></script>
   <script src="script_msg.js"></script>
-
+  <script>
+    function openNav() {
+      document.getElementById("mySidenav").style.width = "250px";
+      $("button").click(function(){
+        $.get("http://www.choozmo.com:8888/history_input", function(data, status){
+            console.log(data)
+          });
+      });
+    }
+    
+    function closeNav() {
+      document.getElementById("mySidenav").style.width = "0";
+    }
+    </script>
   <style>
     #myProgress {
       width: 100%;

+ 13 - 17
main.py

@@ -117,6 +117,19 @@ async def progress_page():
 
 @app.post("/make_anchor_video_v2")
 async def make_anchor_video_v2(req:request2):
+    db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
+    log_table = db['history_input']
+    txt_content_seperate_by_dot = ''
+    for txt in req.text_content:
+        txt_content_seperate_by_dot += txt+","
+    txt_content_seperate_by_dot = txt_content_seperate_by_dot[:-1]
+    img_urls_seperate_by_dot = ''
+    for iurl in req.image_urls:
+        img_urls_seperate_by_dot += iurl+","
+    img_urls_seperate_by_dot = img_urls_seperate_by_dot[:-1]
+    time_stamp = datetime.fromtimestamp(time.time())
+    time_stamp = time_stamp.strftime("%Y-%m-%d %H:%M:%S")
+    pk = log_table.insert({'name':req.name,'text_content':txt_content_seperate_by_dot,'image_urls':img_urls_seperate_by_dot,'timestamp':time_stamp})
     x = threading.Thread(target=anchor_video_v2, args=(req.name, req.text_content, req.image_urls))
     x.start()
     return {"msg":"製作影片需要時間,請您耐心等候  稍後可以在www.choozmo.com:8168/"+req.name+".mp4 中觀看"} 
@@ -140,23 +153,6 @@ async def history_input():
         logs.append({'id':row['id'],'name':row['name'],'text_content':row['text_content'].split(','),'image_urls':row['image_urls'].split(',')})
     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']
-    txt_content_seperate_by_dot = ''
-    for txt in req.text_content:
-        txt_content_seperate_by_dot += txt+","
-    txt_content_seperate_by_dot = txt_content_seperate_by_dot[:-1]
-    img_urls_seperate_by_dot = ''
-    for iurl in req.image_urls:
-        img_urls_seperate_by_dot += iurl+","
-    img_urls_seperate_by_dot = img_urls_seperate_by_dot[:-1]
-    time_stamp = datetime.fromtimestamp(time.time())
-    time_stamp = time_stamp.strftime("%Y-%m-%d %H:%M:%S")
-    pk = log_table.insert({'name':req.name,'text_content':txt_content_seperate_by_dot,'image_urls':img_urls_seperate_by_dot,'timestamp':time_stamp})
-    return pk
-
 def notify_group(msg):
     headers = {
             "Authorization": "Bearer " + "WekCRfnAirSiSxALiD6gcm0B56EejsoK89zFbIaiZQD",