utils.py 366 B

123456789101112
  1. import base64
  2. import requests
  3. url = 'http://0.0.0.0:8080'
  4. def send_request(image_path, image_type):
  5. with open(image_path, 'rb') as f:
  6. img_str: str = base64.encodebytes(f.read()).decode('utf-8')
  7. r = requests.post(f'{url}/ocr_system/schoolcert', json={'image': img_str, 'image_type': image_type})
  8. print(r.json())
  9. return r.json()