简历解析功能通过http请求进行调用,python 调用例子如下:
import os
import requests
import base64
import pprint
api_url_base = 'http://127.0.0.1:5000/api'
api_token = 'tk-1234567890'
def resume_parser(filename: str):
api_url = '{}/resume_parser'.format(api_url_base)
with open(filename, 'rb') as fp:
data = fp.read()
enc_data = base64.b64encode(data).decode()
req = requests.Session()
payload = {
'file_name': os.path.basename(filename),
'file_mode': 1,
'file_cont': enc_data,
'token': api_token
}
res = req.post(api_url, json=payload)
if res.ok:
return res.json()
return (res.status_code, res.reason)
if __name__ == '__main__':
result = resume_parser('张三的简历.docx')
pprint.pprint(result)