config.py 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. blfe_url = 'http://aihubtest.digitalyili.com/aiSquare/openApi/reasoning-services/rlocrxm'
  8. URL = {
  9. 'test': test_url,
  10. 'sb': sb_url,
  11. 'idc': idc_url,
  12. 'blfe': blfe_url
  13. }
  14. # 测试token
  15. test_header = {
  16. 'Content-Type': 'application/json',
  17. 'Authorization': 'Bearer 9679c2b3-b90b-4029-a3c7-f347b4d242f7'
  18. }
  19. sb_header = {
  20. 'Content-Type': 'application/json',
  21. 'Authorization': 'Bearer dcae8cc6-0e49-4db8-a2d2-94ef84da3636'
  22. }
  23. idc_header = {
  24. 'Content-Type': 'application/json',
  25. 'Authorization': 'Bearer 4e00c444-620b-4d3c-85f4-777e64276f0e'
  26. }
  27. blfe_header = {
  28. 'Content-Type': 'application/json',
  29. 'Authorization': 'Bearer 8ae1e5f1-1337-4f22-8d46-ff4c110d68fd'
  30. }
  31. TOKEN = {
  32. 'test': test_header,
  33. 'sb': sb_header,
  34. 'idc': idc_header,
  35. 'blfe': blfe_header
  36. }
  37. def send_request(image_path, suffix, URL, TOKEN):
  38. with open(image_path, 'rb') as f:
  39. img_str: str = base64.encodebytes(f.read()).decode('utf-8')
  40. r = requests.post(f'{URL}{suffix}', json={'image': img_str, 'image_type': '0'}, headers=TOKEN)
  41. return r.json()