diff --git a/.gitignore b/backend/.gitignore similarity index 74% rename from .gitignore rename to backend/.gitignore index 11cf02a..c5713f2 100644 --- a/.gitignore +++ b/backend/.gitignore @@ -2,4 +2,5 @@ test_output test_output/* test_tif -output \ No newline at end of file +output +uploads \ No newline at end of file diff --git a/cp_run.py b/backend/cp_run.py similarity index 100% rename from cp_run.py rename to backend/cp_run.py diff --git a/cp_train.py b/backend/cp_train.py similarity index 100% rename from cp_train.py rename to backend/cp_train.py diff --git a/flaskApp.py b/backend/flaskApp.py similarity index 60% rename from flaskApp.py rename to backend/flaskApp.py index 762b714..f6a6f2c 100644 --- a/flaskApp.py +++ b/backend/flaskApp.py @@ -1,9 +1,13 @@ from flask import Flask, send_from_directory, request, jsonify import os, shutil, time, threading from werkzeug.utils import secure_filename +from flask_cors import CORS +from pathlib import Path app = Flask(__name__) -UPLOAD_DIR = "./uploads" +CORS(app) +BASE_DIR = Path(__file__).resolve().parent +UPLOAD_DIR = BASE_DIR / "uploads" os.makedirs(UPLOAD_DIR, exist_ok=True) def run_flask(): @@ -15,21 +19,21 @@ def index(): @app.route("/testdl") def test_download(): - return send_from_directory("./test_output/2025-09-16-20-03-51", "img_overlay.png", as_attachment=True) + return send_from_directory("test_output/2025-09-16-20-03-51", "img_overlay.png", as_attachment=True) @app.route("/dl/") def download(timestamp): - input_dir = os.path.join("./output", timestamp) - output_dir = os.path.join("./output/tmp", timestamp) # 不要加 .zip,make_archive 会自动加 - os.makedirs("./output/tmp", exist_ok=True) # 确保 tmp 存在 + input_dir = os.path.join("output", timestamp) + output_dir = os.path.join("output/tmp", timestamp) # 不要加 .zip,make_archive 会自动加 + os.makedirs("output/tmp", exist_ok=True) # 确保 tmp 存在 shutil.make_archive(output_dir, 'zip', input_dir) print(f"压缩完成: {output_dir}.zip") - return send_from_directory("./output/tmp", f"{timestamp}.zip", as_attachment=True) + return send_from_directory("output/tmp", f"{timestamp}.zip", as_attachment=True) @app.post("/upload") def upload(): - files = request.files.getlist("files") # ← 前端用同一个键名多次 append + files = request.files.getlist("files") saved = [] for f in files: if not f or f.filename == "": diff --git a/main.py b/backend/main.py similarity index 100% rename from main.py rename to backend/main.py diff --git a/backend/requirements.txt b/backend/requirements.txt new file mode 100644 index 0000000..3ddb55f --- /dev/null +++ b/backend/requirements.txt @@ -0,0 +1,6 @@ +numpy~=2.1.2 +cellpose~=4.0.6 +pillow~=11.0.0 +sympy~=1.13.3 +flask~=3.1.2 +werkzeug~=3.1.3 \ No newline at end of file diff --git a/frontend/index.html b/frontend/index.html new file mode 100644 index 0000000..63398b8 --- /dev/null +++ b/frontend/index.html @@ -0,0 +1,31 @@ + + + + + +