Nasma commited on
Commit
1c8d497
·
verified ·
1 Parent(s): 3ebbf88

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -0
app.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import random
3
+ import time
4
+
5
+ with gr.Blocks() as demo:
6
+ msg = gr.Textbox(label="pregnancies")
7
+ msg1 = gr.Textbox(label="Glucose")
8
+ msg2 = gr.Textbox(label="BloodPressure")
9
+ msg3 = gr.Textbox(label="SkinThickness")
10
+ msg4 = gr.Textbox(label="Insulin")
11
+ msg5 = gr.Textbox(label="BMI")
12
+ msg6 = gr.Textbox(label="DiabetesPedigreeFunction")
13
+ msg7 = gr.Textbox(label="Age")
14
+ button =gr.Button("Submit")
15
+ result = gr.Textbox(label="predicted result")
16
+
17
+
18
+ def respond(msg, msg1,msg2,msg3,msg4,msg5,msg6,msg7):
19
+ import requests
20
+ import json
21
+
22
+ url = "https://nasma-arafath.hf.space/diabetes_prediction"
23
+
24
+ payload = json.dumps({
25
+ "pregnancies": msg,
26
+ "Glucose": msg1,
27
+ "BloodPressure": msg2,
28
+ "SkinThickness": msg3,
29
+ "Insulin": msg4,
30
+ "BMI": msg5,
31
+ "DiabetesPedigreeFunction": msg6,
32
+ "Age": msg7
33
+ })
34
+ headers = {
35
+ 'accept': 'application/json',
36
+ 'Content-Type': 'application/json'
37
+ }
38
+
39
+ response = requests.request("POST", url, headers=headers, data=payload)
40
+
41
+ print(response.text)
42
+
43
+
44
+ return response.text
45
+
46
+ button.click(respond, [msg, msg1,msg2,msg3,msg4,msg5,msg6,msg7], [result])
47
+
48
+ if __name__ == "__main__":
49
+ demo.launch()