A FastAPI-based proxy service for Caoliao QR code recognition API.
- Proxy service for Caoliao QR code recognition
- Supports image file upload and QR code content decoding
- Automatic API request handling and response transformation
Parameters:
file: Image file in multipart/form-data format
Success Response:
{
"content": "decoded QR code content"
}Error Responses:
- 400: Upload/Decode failure
- 502: Third-party API returned invalid data
curl -X POST -F "file=@qrcode.jpg" http://localhost:8000/decode_qrcode/
400 Bad Request: Upload or decode failure502 Bad Gateway: Third-party API returned invalid data
- Install dependencies:
pip install fastapi uvicorn aiohttp python-multipart
- Run the service:
python app.py
The service will be available at http://localhost:8000
pip install pytest requests pillow qrcode[pil]
- First start the service:
python app.py
- In a new terminal, run API tests:
python -m unittest test.test
- Valid QR code: Returns 200 status with
contentfield - Invalid file: Returns 400 status with
errorfield
bobo
v1.1