config.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import base64
  2. import requests
  3. # 测试url
  4. TX_test_url = 'http://aihubtest.digitalyili.com/aiSquare/openApi/reasoning-services/rlocrxm'
  5. TX_sb_url = 'http://aihub.digitalyili.com/aiSquare/openApi/reasoning-services/rlocrxm'
  6. DX_test_url = 'http://aihubpre-idc.digitalyili.com/aiSquare/openApi/reasoning-services/hrocr'
  7. DX_sb_url = 'http://aihub-idc.digitalyili.com/aiSquare/openApi/reasoning-services/hrocr'
  8. URL = {
  9. 'TX_test': TX_test_url,
  10. 'TX_sb': TX_sb_url,
  11. 'DX_test': DX_test_url,
  12. 'DX_sb': DX_sb_url
  13. }
  14. DX = {
  15. }
  16. # 测试token
  17. TX_test = {'Authorization': 'Bearer 8ae1e5f1-1337-4f22-8d46-ff4c110d68fd'}
  18. TX_sb = {'Authorization': 'Bearer dcae8cc6-0e49-4db8-a2d2-94ef84da3636'}
  19. DX_test = {'Authorization': 'Bearer 4e00c444-620b-4d3c-85f4-777e64276f0e'}
  20. DX_sb = {'Authorization': 'Bearer e045de0a-e97f-4f23-b4d5-6a032c39a81e'}
  21. TOKEN = {
  22. 'TX_test': TX_test,
  23. 'TX_sb': TX_sb,
  24. 'DX_test': DX_test,
  25. 'DX_sb': DX_sb
  26. }
  27. def send_request(image_path, suffix, URL, TOKEN):
  28. with open(image_path, 'rb') as f:
  29. img_str: str = base64.encodebytes(f.read()).decode('utf-8')
  30. r = requests.post(f'{URL}{suffix}', json={'image': img_str, 'image_type': '0'}, headers=TOKEN)
  31. return r.json()