jared 3 years ago
parent
commit
b8c5a88921
1 changed files with 5 additions and 4 deletions
  1. 5 4
      web/main.py

+ 5 - 4
web/main.py

@@ -10,6 +10,7 @@ from pydantic import BaseModel
 from fastapi import FastAPI, Form
 import subprocess
 import suggests
+from typing import Optional
 import networkx as nx
 import pyvis
 import time
@@ -71,8 +72,8 @@ def thread_function(kw):
 @app.get("/tree_list/",response_class=HTMLResponse)
 async def tree_list():
     global db
-    html="<html><body><h2>清單</h2></br>請一分鐘後refresh </br>"
-    html+="<table>"
+    html="<html><body><h2>清單</h2></br>請一分鐘後refresh </br></br>"
+    html+="<table border='1'>"
     cursor=db.query('select filename,kw from gen_graph order by id desc limit 10')
     for c in cursor:
         html+="<tr><td>"+c['kw']+"</td>"
@@ -84,11 +85,11 @@ async def tree_list():
 
 #response_class=RedirectResponse
 @app.post("/gen_tree/",response_class=HTMLResponse)
-async def func_expand(kw: str = Form(...),kw2: str = Form(...)):
+async def func_expand(kw: str = Form(...),kw2:Optional[str] = Form(None) ):
     kwlst=[]
     if len(kw)>1:
         kwlst.append(kw)    
-    if len(kw2)>1:
+    if kw2 is not None:
         kwlst.append(kw2)    
 
     x = threading.Thread(target=thread_function, args=(kwlst,))