changxin commited on
Commit
157537f
1 Parent(s): 9f8a098

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -0
app.py CHANGED
@@ -29,6 +29,15 @@ def fx_m(s:str):
29
  respose=requests.post(url,json=data,headers=headers)
30
  ms=respose.json()
31
  return ms['result']
 
 
 
 
 
 
 
 
 
32
 
33
  demo=gr.Blocks()
34
  with demo:
@@ -51,5 +60,13 @@ with demo:
51
  M_output=gr.Textbox(label="格式化结果",lines=50)
52
  M_button=gr.Button("开始格式化>>")
53
  M_button.click(fx_m, inputs=M_input, outputs=M_output,api_name='M')
 
 
 
 
 
 
 
 
54
  demo.launch()
55
 
 
29
  respose=requests.post(url,json=data,headers=headers)
30
  ms=respose.json()
31
  return ms['result']
32
+
33
+ def fx_dax(s:str):
34
+ url="https://www.daxformatter.com/"
35
+ data = {"embed":"1","l":"short","fx":s}
36
+ ct=requests.post(url = url,data = data)
37
+ html=ct.text
38
+ s1=html.split('<div class="result">')[1]
39
+ s2='<div class="result">'+s1.split('<a href')[0]
40
+ return s2
41
 
42
  demo=gr.Blocks()
43
  with demo:
 
60
  M_output=gr.Textbox(label="格式化结果",lines=50)
61
  M_button=gr.Button("开始格式化>>")
62
  M_button.click(fx_m, inputs=M_input, outputs=M_output,api_name='M')
63
+
64
+ with gr.TabItem("DAX-Formatter"):
65
+ gr.Markdown("# DAX表达式格式化测试")
66
+ with gr.Row():
67
+ DAX_input=gr.Textbox(label="请填写需要格式化的DAX表达式",default="扯淡=CALCULATE(VALUES('价格表'[单价]),FILTER('价格表','价格表'[产品]='销售表'[产品]))",lines=28)
68
+ DAX_button=gr.Button("格式化>>")
69
+ DAX_output=gr.HTML(label="DAX表达式格式化结果")
70
+ DAX_button.click(fx_dax, inputs=DAX_input, outputs=DAX_output,api_name='DAX')
71
  demo.launch()
72