deepsync commited on
Commit
534de65
·
verified ·
1 Parent(s): c15604e

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +31 -0
app.py ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio
3
+ import requests
4
+
5
+ headers = {
6
+ 'accept': 'application/json',
7
+ 'Content-Type': 'application/json',
8
+ 'Authorization': f'Bearer {os.environ.get("USERNAME")}:{os.environ.get("PASSWORD")}'
9
+ }
10
+
11
+ def trigger(id):
12
+ json_data = {
13
+ 'conf': {
14
+ 'id': id.strip(),
15
+ },
16
+ }
17
+ response = requests.post(f'http://{os.environ.get("IP_ADDRESS")}:8080/api/v1/dags/{os.environ.get("DAG_ID")}/dagRuns', headers=headers, json=json_data)
18
+ return response.status_code
19
+
20
+ id_name = gradio.Textbox(label="ID")
21
+ response_status = gradio.Textbox(label="Response Status")
22
+
23
+ interface = gradio.Interface(
24
+ trigger,
25
+ id_name,
26
+ response_status,
27
+ title="Edit Trigger"
28
+ )
29
+
30
+ if __name__=="__main__":
31
+ interface.launch(auth=(os.environ.get("GRADIO_USERNAME"), os.environ.get("GRADIO_PASSWORD")))