From 92a89f856a2cdb6e78e749d23056a1b940ea4884 Mon Sep 17 00:00:00 2001 From: ClovertaTheTrilobita Date: Tue, 16 Sep 2025 22:41:05 +0300 Subject: [PATCH] =?UTF-8?q?feature(frontend):=20=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=B7=B3=E8=BD=AC=E8=87=B3=E9=A2=84=E8=A7=88?= =?UTF-8?q?=20TODO:=20=E8=8E=B7=E5=8F=96=E7=9A=84=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=8F=91=E9=80=81=E7=BB=99cellpose=EF=BC=8C=E5=B0=86cellpose?= =?UTF-8?q?=E7=9A=84=E8=BF=90=E8=A1=8C=E7=8A=B6=E6=80=81=E3=80=81=E9=A2=84?= =?UTF-8?q?=E8=A7=88=E5=8F=91=E9=80=81=E7=BB=99=E5=89=8D=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/flaskApp.py | 8 +++++--- frontend/index.html | 2 ++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/backend/flaskApp.py b/backend/flaskApp.py index f6a6f2c..5f1dc7e 100644 --- a/backend/flaskApp.py +++ b/backend/flaskApp.py @@ -1,5 +1,5 @@ from flask import Flask, send_from_directory, request, jsonify -import os, shutil, time, threading +import os, shutil, time, threading, datetime from werkzeug.utils import secure_filename from flask_cors import CORS from pathlib import Path @@ -33,12 +33,14 @@ def download(timestamp): @app.post("/upload") def upload(): + ts = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S") + os.makedirs(UPLOAD_DIR / ts, exist_ok=True) files = request.files.getlist("files") saved = [] for f in files: if not f or f.filename == "": continue name = secure_filename(f.filename) - f.save(os.path.join(UPLOAD_DIR, name)) + f.save(os.path.join(UPLOAD_DIR / ts, name)) saved.append(name) - return jsonify({"ok": True, "count": len(saved), "files": saved}) \ No newline at end of file + return jsonify({"ok": True, "count": len(saved), "files": saved, "id": ts}) \ No newline at end of file diff --git a/frontend/index.html b/frontend/index.html index 63398b8..d7a91a8 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -1,3 +1,4 @@ + @@ -22,6 +23,7 @@ document.getElementById("uploadBtn").addEventListener("click", async () => { // 不要显式设置 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 {