config.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import base64
  2. import requests
  3. # 测试url
  4. test_url = 'http://aihub-test.digitalyili.com/aiSquare/openApi/reasoning-services/rlocrxm'
  5. sb_url = 'http://aihub.digitalyili.com/aiSquare/openApi/reasoning-services/rlocrxm'
  6. idc_url = 'http://aihubpre-idc.digitalyili.com/aiSquare/openApi/reasoning-services/hrocr'
  7. URL = {
  8. 'test': test_url,
  9. 'sb': sb_url,
  10. 'idc': idc_url
  11. }
  12. # 测试token
  13. test_header = {
  14. 'Content-Type': 'application/json',
  15. 'Authorization': 'Bearer 9679c2b3-b90b-4029-a3c7-f347b4d242f7'
  16. }
  17. sb_header = {
  18. 'Content-Type': 'application/json',
  19. 'Authorization': 'Bearer dcae8cc6-0e49-4db8-a2d2-94ef84da3636'
  20. }
  21. idc_header = {
  22. 'Content-Type': 'application/json',
  23. 'Authorization': 'Bearer 4e00c444-620b-4d3c-85f4-777e64276f0e'
  24. }
  25. TOKEN = {
  26. 'test': test_header,
  27. 'sb': sb_header,
  28. 'idc': idc_header
  29. }
  30. def send_request(image_path, suffix, URL, TOKEN):
  31. with open(image_path, 'rb') as f:
  32. img_str: str = base64.encodebytes(f.read()).decode('utf-8')
  33. r = requests.post(f'{URL}{suffix}', json={'image': img_str, 'image_type': '0'}, headers=TOKEN)
  34. return r.json()