1234567891011121314151617181920212223242526272829303132333435363738 |
- import base64
- import requests
- # 测试url
- TX_test_url = 'http://aihubtest.digitalyili.com/aiSquare/openApi/reasoning-services/rlocrxm'
- TX_sb_url = 'http://aihub.digitalyili.com/aiSquare/openApi/reasoning-services/rlocrxm'
- DX_test_url = 'http://aihubpre-idc.digitalyili.com/aiSquare/openApi/reasoning-services/hrocr'
- DX_sb_url = 'http://aihub-idc.digitalyili.com/aiSquare/openApi/reasoning-services/hrocr'
- URL = {
- 'TX_test': TX_test_url,
- 'TX_sb': TX_sb_url,
- 'DX_test': DX_test_url,
- 'DX_sb': DX_sb_url
- }
- DX = {
- }
- # 测试token
- TX_test = {'Authorization': 'Bearer 8ae1e5f1-1337-4f22-8d46-ff4c110d68fd'}
- TX_sb = {'Authorization': 'Bearer dcae8cc6-0e49-4db8-a2d2-94ef84da3636'}
- DX_test = {'Authorization': 'Bearer 4e00c444-620b-4d3c-85f4-777e64276f0e'}
- DX_sb = {'Authorization': 'Bearer e045de0a-e97f-4f23-b4d5-6a032c39a81e'}
- TOKEN = {
- 'TX_test': TX_test,
- 'TX_sb': TX_sb,
- 'DX_test': DX_test,
- 'DX_sb': DX_sb
- }
- def send_request(image_path, suffix, URL, TOKEN):
- with open(image_path, 'rb') as f:
- img_str: str = base64.encodebytes(f.read()).decode('utf-8')
- r = requests.post(f'{URL}{suffix}', json={'image': img_str, 'image_type': '0'}, headers=TOKEN)
- return r.json()
|