Spaces:
Runtime error
Runtime error
Download app.py from handwriting-ocr-api/handwriting-ocr: direct link, hf CLI and curl.
- Browser
- Download file 673 Bytes
-
https://huggingface.co/spaces/handwriting-ocr-api/handwriting-ocr/resolve/main/app.py
- Command line
-
hf download hf://spaces/handwriting-ocr-api/handwriting-ocr/app.py
-
curl -L -o app.py https://huggingface.co/spaces/handwriting-ocr-api/handwriting-ocr/resolve/main/app.py
673 Bytes
| from flask import Flask, request, jsonify | |
| from api.inference import OCRPredictor | |
| app = Flask(__name__) | |
| predictor = OCRPredictor() | |
| async def predict(): | |
| try: | |
| if 'file' not in request.files: | |
| return jsonify({'error': 'No file part'}), 400 | |
| file = request.files['file'] | |
| if file.filename == '': | |
| return jsonify({'error': 'No selected file'}), 400 | |
| result = await predictor.predict_character(file) | |
| return jsonify(result) | |
| except Exception as e: | |
| return jsonify({'error': str(e)}), 500 | |
| if __name__ == "__main__": | |
| app.run(host="0.0.0.0", port=7860) |