changxin commited on
Commit
da43c80
1 Parent(s): b24edfb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -1
app.py CHANGED
@@ -51,6 +51,14 @@ def fx_dd(tk:str,s:str):
51
  response=requests.post(url,json=data,headers=headers)
52
  return response.text
53
 
 
 
 
 
 
 
 
 
54
  demo=gr.Blocks()
55
  with demo:
56
  with gr.Tabs():
@@ -93,6 +101,13 @@ with demo:
93
  dd_input=[gr.Textbox(label="请填写机器人token"),gr.Textbox(label="请填写需要推送的信息",lines=10)]
94
  dd_output=gr.Textbox(label="推送提示")
95
  dd_button=gr.Button("提交")
96
- dd_button.click(fx_dd, inputs=dd_input, outputs=dd_output,api_name='dingding')
 
 
 
 
 
 
 
97
  demo.launch()
98
 
 
51
  response=requests.post(url,json=data,headers=headers)
52
  return response.text
53
 
54
+ def dd_ocr(tk:str,sl:str,dt:str):
55
+ headers= {"Content-Type": "application/json"}
56
+ url="https://oapi.dingtalk.com/topapi/ocr/structured/recognize?access_token="+tk
57
+ dc={"身份证":"idcard","增值税发票":"invoice","营业执照":"blicense","银行卡":"bank_card","车牌":"car_no","机动车发票":"car_invoice","驾驶证":"driving_license","行驶证":"vehicle_license","火车票":"train_ticket","定额发票":"quota_invoice","出租车发票":"taxi_ticket","机票行程单":"air_itinerary","审批表单":"approval_table","花名册":"roster"}
58
+ data={"image_url":sl,"type":dc[dt]}
59
+ response=requests.post(url,json=data,headers=headers)
60
+ return response.json()
61
+
62
  demo=gr.Blocks()
63
  with demo:
64
  with gr.Tabs():
 
101
  dd_input=[gr.Textbox(label="请填写机器人token"),gr.Textbox(label="请填写需要推送的信息",lines=10)]
102
  dd_output=gr.Textbox(label="推送提示")
103
  dd_button=gr.Button("提交")
104
+ dd_button.click(fx_dd, inputs=dd_input, outputs=dd_output,api_name='dingding_robot')
105
+
106
+ with gr.TabItem("钉钉ocr"):
107
+ gr.Markdown("# 网络图片OCR识别")
108
+ ocr_input=[gr.Textbox(label="请填写ocr_token"),gr.Textbox(label="请填写图片网址"),gr.Radio(["身份证","增值税发票","营业执照","银行卡","车牌","机动车发票","驾驶证","行驶证","火车票","定额发票","出租车发票","机票行程单","审批表单","花名册"],"营业执照增值税发票",label="请选择识别类型:")]
109
+ ocr_button=gr.Button("开始识别>>")
110
+ ocr_output=gr.JSON(label="识别结果")
111
+ ocr_button.click(fx_dd, inputs=ocr_input, outputs=ocr_output,api_name='dingding_ocr')
112
  demo.launch()
113