瀏覽代碼

fix progress bar

ming 3 年之前
父節點
當前提交
d5eb218100
共有 2 個文件被更改,包括 39 次插入1 次删除
  1. 7 0
      main.py
  2. 32 1
      progress.html

+ 7 - 0
main.py

@@ -115,6 +115,13 @@ async def swapFace(req:swap_req):
     result = sf.run()
     #notify_group(result)
     return result
+
+@app.post("/autoprogress")
+async def autoprogress(req:swap_req):
+    ws = create_connection("ws://www.choozmo.com:8888/progress")
+    for i in range(100)
+        time.sleep(0.1)
+        ws.send(i)
     
 
 @app.post("/make_anchor_video_v2")

+ 32 - 1
progress.html

@@ -42,10 +42,41 @@
 </div>
 
 <br>
-<button onclick="move()">Click Me</button> 
+<button onclick="move2()">Click Me</button> 
 
 <script>
+
+var ws = new WebSocket('ws://www.choozmo.com:8888/progress');
+          ws.onmessage = function(event) {
+              console.log(event.data);
+              var elem = document.getElementById("myBar");
+              elem.style.width = event.data + "%";
+              elem.innerHTML = event.data  + "%";
+          };
+          function sendMessage(event) {
+              var input = document.getElementById("messageText")
+              ws.send(input.value)
+              input.value = ''
+              event.preventDefault()
+          }
 var i = 0;
+function move2(){
+  $.ajax({
+	url: 'http://www.choozmo.com:8888/autoprogress',
+	//url: 'http://www.choozmo.com:8888/qqreq',
+	dataType : 'json', // 預期從server接收的資料型態
+  contentType : 'application/json; charset=utf-8', // 要送到server的資料型態
+	type: 'post',
+	data: JSON.stringify({'imgurl':'non'}),
+	success: function(suc_data) {
+    alert(suc_data.msg)
+	  },
+	//data:JSON.stringify({n1:"12",n2:"22"}),
+	error: function (error) {
+	  alert(error)
+	}
+});
+}
 function move() {
   if (i == 0) {
     i = 1;