diff --git a/ocr.py b/ocr.py index 1a54ce22ee09d8c4f648f03b5a974b2ed229e941..ec36150a48d77f7adefde8a1d78c972da34cc6cb 100644 --- a/ocr.py +++ b/ocr.py @@ -27,4 +27,10 @@ def ocr_inference(): file = request.files["file"] if file.filename == "": - return jsonify({"error": "No selected file"}), 400 \ No newline at end of file + return jsonify({"error": "No selected file"}), 400 + + # 生成唯一文件名 + uuid_str = str(uuid.uuid4()) + filename = f"{uuid_str}.jpg" + image_path = os.path.join(upload_dir, filename) + file.save(image_path) \ No newline at end of file