get_imgcode.py 787 B

123456789101112131415161718192021
  1. import requests
  2. from typing import Mapping
  3. def get_code(file_path: str) -> dict:
  4. upload_address = "http://123.57.163.80:2119/v1/images/verify"
  5. with open(file_path, 'rb') as f:
  6. image_bytes = f.read()
  7. content = {'file': image_bytes}
  8. # json_resp = get_verify_code(upload_address, content)
  9. headers = {'accept': 'application/json'}
  10. response = requests.post(upload_address, headers=headers, files=content, stream=True)
  11. return response.json()
  12. def get_code_det(image_bytes) -> dict:
  13. upload_address = "http://123.57.163.80:2119/v1/images/verify_det"
  14. content = {'image_content': image_bytes}
  15. headers = {'accept': 'application/json'}
  16. response = requests.post(upload_address, headers=headers, files=content, stream=True)
  17. return response.json()