From 3ebc7ca90980519ecb621d88fa633817f29120a7 Mon Sep 17 00:00:00 2001 From: ClovertaTheTrilobita Date: Thu, 18 Sep 2025 16:57:14 +0300 Subject: [PATCH] =?UTF-8?q?feature(run):=20=E6=B7=BB=E5=8A=A0=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/flaskApp.py | 3 ++ frontend/index.html | 75 ++++++++++++++++++++++++++++++++------------- 2 files changed, 56 insertions(+), 22 deletions(-) diff --git a/backend/flaskApp.py b/backend/flaskApp.py index ed4f710..03b85bf 100644 --- a/backend/flaskApp.py +++ b/backend/flaskApp.py @@ -69,6 +69,9 @@ def upload(): diameter_raw = request.args.get("diameter") or request.form.get("diameter") diameter = _to_float(diameter_raw, None) if diameter_raw not in (None, "") else None + print("cpt:" + str(cellprob_threshold)) + print("flow:" + str(flow_threshold)) + # 将文件保存在本地目录中 ts = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S") + f"-{int(time.time()*1000)%1000:03d}" os.makedirs(UPLOAD_DIR / ts, exist_ok=True) diff --git a/frontend/index.html b/frontend/index.html index d7a91a8..47ed71f 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -2,32 +2,63 @@ +


+ +

+ +

+ + + document.getElementById("uploadBtn").addEventListener("click", async () => { + const input = document.getElementById("fileInput"); + if (!input.files.length) return alert("请选择文件"); + + const fd = new FormData(); + for (const f of input.files) fd.append("files", f); + + const bar = document.getElementById("bar"); + try { + const URL = buildUrl(); + const res = await axios.post(URL, fd, { + onUploadProgress: (e) => { + if (e.total) bar.value = Math.round((e.loaded * 100) / e.total); + }, + // 不要显式设置 Content-Type + }); + alert("上传成功:" + JSON.stringify(res.data)); + window.location.href = `preview.html?id=${encodeURIComponent(res.data['id'])}`; + } catch (e) { + alert("上传失败:" + (e.response?.data?.message || e.message)); + } finally { + bar.value = 0; + } + }); + \ No newline at end of file