diff --git a/README.MD b/README.MD index b2099fe..fbcdeaa 100644 --- a/README.MD +++ b/README.MD @@ -123,6 +123,12 @@ if __name__ == "__main__": # result = ocr_recognize(image_url="https://example.com/image.png") ``` +### test + +```bash +bash test.sh +``` + ## Project Structure - `main.py`: The Flask API service that handles OCR requests diff --git a/main.py b/main.py index e979eaf..63b669a 100644 --- a/main.py +++ b/main.py @@ -69,6 +69,18 @@ def index(): return render_template("index.html") +# Handle unsupported methods for /ocr route +@app.route("/ocr", methods=["GET", "PUT", "DELETE", "PATCH"]) +def unsupported_method(): + return jsonify({"error": "Method not allowed"}), 405 + + +# Handle non-existent paths +@app.errorhandler(404) +def not_found(e): + return jsonify({"error": "Resource not found"}), 404 + + if __name__ == "__main__": # 确保templates目录存在 templates_dir = os.path.join(