-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAPI.py
30 lines (27 loc) · 1005 Bytes
/
API.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#InnovationChallenge Project
import requests
import json
import time
while(1):
with open('input.txt', 'r') as file:
data = file.read().split('/', 13)
#List of the Symptoms is always - data[12]
print(data)
if(len(data)>2):
Symptoms = ((data[12].replace(" ,", ",")).replace(", ", ",")).replace(' ', '_')
URL = "http://localhost:5000/?symptoms="+Symptoms
response = requests.get(URL)
print(URL)
if response.status_code == 200:
Output = json.loads(response.text)
print(Output.get('data'))
outFile = open("Output.txt", "w")
stringOutput = Output.get('data')
text = "First Name: " + data[0] + "\n" + "Last Name: " + data[1] + "\n" + "AGE: " + data[2] + "\n" + "Predicted prognosis: " + stringOutput
write = outFile.write(text)
outFile.close()
elif response.status_code == 500:
print("Unsuffice Data Provided")
else:
print("Error. Check Server")
time.sleep(2)