utils.py 511 B

12345678910111213141516171819
  1. import base64
  2. import requests
  3. url = 'http://192.168.199.249:2991'
  4. # url = 'http://aihub-test.digitalyili.com/aiSquare/openApi/reasoning-services/rlocrxm'
  5. # header = {
  6. # 'Authorization': 'Bearer 9679c2b3-b90b-4029-a3c7-f347b4d242f7'
  7. # }
  8. def send_request(image_path):
  9. with open(image_path, 'rb') as f:
  10. img_str: str = base64.encodebytes(f.read()).decode('utf-8')
  11. r = requests.post(f'{url}/ocr_system/bankcard', json={'image': img_str})
  12. print(r.json())
  13. return r.json()