KongYang commited on
Commit
0fed72b
1 Parent(s): 896b3aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +59 -48
app.py CHANGED
@@ -1,4 +1,4 @@
1
- import time
2
  from datetime import datetime,timedelta
3
  import requests ,re
4
  import gradio as gr
@@ -140,64 +140,75 @@ def pay(auth_id):
140
 
141
 
142
  else:
143
- return "🈲无法查询到车辆入场信息"
144
  except Exception as e:
145
  print("异常>>>>>>>>>>>问题原因:",e )
146
  return "🚫请求异常"
147
 
148
 
149
 
150
-
151
- # a =pay(0)
152
- # print(a)
153
- authorization_list = [
154
- # 9月22
155
- "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsImp0aSI6ImE5ZWJiNDFlOGQ4YjQ3MTg5YmEwNmVlOGRiNzM1OGRiMDFkYzhmNGJhNDZhYWJlOThiNmExM2I4ZmZiZTljYWRhYzAyYjFiYWY3M2QyZTA3In0.eyJhdWQiOiIyIiwianRpIjoiYTllYmI0MWU4ZDhiNDcxODliYTA2ZWU4ZGI3MzU4ZGIwMWRjOGY0YmE0NmFhYmU5OGI2YTEzYjhmZmJlOWNhZGFjMDJiMWJhZjczZDJlMDciLCJpYXQiOjE3MjY5ODAzNjMsIm5iZiI6MTcyNjk4MDM2MywiZXhwIjoxNzI5NTcyMzYzLCJzdWIiOiI5NTM2MzkiLCJzY29wZXMiOlsiKiJdfQ.GQEdqovMWk0RgsE8M3RyKP-YhGlg8ZubxtEf57azXk786mXGwSx8WIEl_gVOcgy9zzC6YA26i_iUcJpDgtT-yFT2utqUpZS4LCoS0VYCQzXkDmYAPeypjgyK0WYHJ10EBSq6un1dljkIW2kRzKMOsn_Gq3L8jPGgQb4wyErllXpQETdCxoSX90diup7XjGqevhgLQJNmpcK5zv5kp1JCaMXzaqu9c7TnBTefM_pKcKD5P-18ftGIkHpCHcBDUTti3AzCVfrbWqhDRyM1MzQzp7pTL7d0K2YlQ36QgmIaphDrvhLeJCwwpGO1rfyG-ubiEBXisNNMUA9n63VRQ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mnj1ZnTKU64lT_Y7wRW7A7yGRgVrjF0kntw0kkEulCKkgTNmCcTq-tLNFlNPCIpWldJzptyvxj_737gc6yafm6vohDAkQ-uwkuKqyjEpR2yqlivH0d7Pk4wMwg-fDHEbg_D55fYJJAozv0a9PU_oUb29RX8_1XBpe5iKcR9yqjj1H1txp3e2ilJHw0Ttka-xDrCc2LWScUnE5vaQgILTJz15lEY6OeAGsh6DmAA0tu0_utH9sNgx8QDxNaAXpIW5BLfyo5CzY4ZwWuV-wVweY5s3HKUQx6i56wnSHsNYyARwRHiCIk3rSnOD3vALV77L9uDab49-vV2JWArdESiFxtibQbyGsfwXdGTH8Qwu09En9n0hR2B6lNJD7srEBFcGCLztUagiJplhLPIKd4cRT5zCp9OZGw9TFr7mtKZjNS21SVLg8BO2DwFYTfuBrOLlmvAQetGS1gablT3mo86DGS5Kvl9Cmvcujmjco1Czsa8JjPTMlD_z_OmmAci2XA-5w6BcrxJiOiwNTcELJhRGZARuNf25D52Qrx6poPFSWU5BYUTzjqblUD1cl2bUKivWwR4Hkadofk",
162
-
163
- ]
164
-
165
- radio_num = []
166
- for k,v in enumerate(authorization_list):
167
- if v.startswith("Bearer"):
168
- radio_num.append(k)
169
- # print(k,v)
170
-
171
-
172
  history = []
173
 
174
  with gr.Blocks() as demo:
 
 
175
 
176
- query_button = gr.Button("查询")
177
- @query_button.click(inputs=None, outputs= gr.Json(label="查询结果"))
178
- def query_click():
179
- authorization = authorization_list[0]
180
- # print("authorization:",authorization)
181
- first_results = request_first(authorization)
182
- third_no,fee,begin,duration,user_id = first_results
183
-
184
- return {"费用":fee,"入场时间":begin,"时长":duration}
185
-
186
 
 
 
 
187
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
 
189
- # 输入组件:单选按钮
190
- auth_id = gr.Radio(radio_num, label="选择授权ID")
191
- # 输出组件:文本和 DataFrame
192
- output = gr.Dataframe(headers=["支付时间", "支付结果", "使用ID"], label="支付历史")
193
-
194
- # 支付按钮组件
195
- pay_button = gr.Button("支付")
196
- @pay_button.click(inputs=auth_id, outputs= output)
197
- def pay_click(auth_id):
198
- pay_result = pay(auth_id)
199
- history.append([str((datetime.now()+ timedelta(hours=6)).strftime("%Y-%m-%d %H:%M:%S")) , str(pay_result) ,str(auth_id) ])
200
- return history
201
-
202
 
203
- demo.launch(auth=("admin", "eyJ0eXAiOiJKV1QiLCJhbGciOiJUzI1NiIsI"))
 
 
1
+ import time ,json
2
  from datetime import datetime,timedelta
3
  import requests ,re
4
  import gradio as gr
 
140
 
141
 
142
  else:
143
+ return "🚷无法查询到车辆入场信息"
144
  except Exception as e:
145
  print("异常>>>>>>>>>>>问题原因:",e )
146
  return "🚫请求异常"
147
 
148
 
149
 
150
+ # 读取authorization.json
151
+ with open("authorization.json") as f:
152
+ authorization_list = json.load(f)
153
+ # print("authorization_list:",authorization_list)
154
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  history = []
156
 
157
  with gr.Blocks() as demo:
158
+ # 输入组件:单选按钮
159
+ auth_id = gr.Radio(authorization_list, label="选择授权ID")
160
 
161
+ with gr.Row():
162
+ with gr.Column(scale=2):
 
 
 
 
 
 
 
 
163
 
164
+ query_button = gr.Button("查询")
165
+ # @query_button.click(inputs=auth_id, outputs= gr.Json(label="查询结果"))
166
+ @query_button.click(inputs=auth_id, outputs= gr.Dataframe(headers=["费用", "入场时间", "时长"], label="查询结果"))
167
 
168
+
169
+ def query_click(auth_id):
170
+ if auth_id == None:
171
+ auth_id = "0"
172
+ authorization = authorization_list[auth_id]
173
+ # print("authorization:",authorization)
174
+ first_results = request_first(authorization)
175
+ third_no,fee,begin,duration,user_id = first_results
176
+
177
+ # return {"费用":fee,"入场时间":begin,"时长":duration}
178
+ return [(fee,begin,duration)]
179
+
180
+ # -------------------------------------------------------------------------
181
+ with gr.Column(scale=3):
182
+ # 支付按钮组件
183
+ pay_button = gr.Button("支���")
184
+ @pay_button.click(inputs=auth_id, outputs= gr.Dataframe(headers=["支付时间", "支付结果", "使用ID"], label="支付历史"))
185
+ def pay_click(auth_id):
186
+ pay_result = pay(auth_id)
187
+ if auth_id == 0 and pay_result[0:5] == "✅缴费成功":
188
+ history.clear()
189
+ history.append([str((datetime.now()+ timedelta(hours=6)).strftime("%Y-%m-%d %H:%M:%S")) , str(pay_result) ,str(auth_id) ])
190
+ return history
191
+
192
+
193
+ # -------------------------------------------------------------------------
194
+ bearer_input = gr.DataFrame(headers=[ "auth_bearer"],
195
+ datatype=["str"],
196
+ value=[],
197
+ row_count=4,
198
+ col_count=(1, "fixed"))
199
+ bearerUpdate_button = gr.Button("更新authorization_list")
200
+ @bearerUpdate_button.click(inputs=bearer_input,outputs= gr.Json(label="授权码列表"))
201
 
202
+ def bearerUpdate_click(new_authorization_list):
203
+ authorization_list.clear()
204
+ for k,v in enumerate(new_authorization_list["auth_bearer"]):
205
+ if v != '':
206
+ authorization_list[str(k)] = v
207
+ # print("authorization_list:",authorization_list)
208
+ with open("authorization.json", "w") as f:
209
+ json.dump(authorization_list, f)
210
+
211
+ return authorization_list
 
 
 
212
 
213
+ demo.launch(auth=("admin", "eyJ0eXAiOiJKV1QiLCJhbGciOiJUzI1NiIsI"))
214
+