commit updated flask files

parent 64440adc
......@@ -8,124 +8,103 @@ from flask_restful import Api,Resource
import disapi
import mlapi
import medi
import json
app = Flask(__name__)
@app.route("/disease", methods=["GET"])
@app.route("/disease", methods=["POST"])
def disease():
request_data = request.get_json()
print (type(request_data))
request_data = str(request_data)
print(type(request_data))
request_data = request_data.replace('{', '')
request_data = request_data.replace('}', '')
request_data = request_data.split(':')
request_data=request_data[1]
print(request_data)
a = request_data["weight_loss"]
b = request_data["loss_of_appetite"]
c = request_data["swollen_joints"]
d = request_data["lameness"]
e = request_data["nasal_discharge"]
f = request_data["ocular_discharge"]
g = request_data["ruffled_feathers"]
h = request_data["diarrhea"]
i = request_data["mites"]
j = request_data["egg_production_decrease"]
k = request_data["inability_to_absorb_nutrients"]
l = request_data["distinctive_bumps"]
m = request_data["warts"]
n = request_data["stunted_growth"]
o = request_data["edema_in_the_comb"]
p = request_data["discoloration"]
q = request_data["coughing_and_sneezing"]
r = request_data["swelling"]
s = request_data["rales"]
t = request_data["gasping"]
u = request_data["muscular_tremors"]
v = request_data["opisthotonus"]
w = request_data["Closed_eyes"]
x = request_data["facial_swelling"]
y = request_data["increased_thirst"]
z = request_data["lethargy"]
a1 = request_data["profuse_tear_secretion"]
b1 = request_data["facial_skin_edema"]
c1 = request_data["progressing_tremors"]
d1 = request_data["drowsy"]
e1 = request_data["head_droop"]
f1 = request_data["laying_on_ground"]
g1 = request_data["Thick_large_white_patches_on_the_inside_the_mouth_and_crop_areas"]
h1 = request_data["Crusty_looking_eyes"]
i1 = request_data["hyperemic"]
j1 = request_data["high_fever"]
k1 = request_data["paralysis"]
l1 = request_data["dehydration"]
m1 = request_data["unkempt_feathers"]
n1 = request_data["yellow_fecal_droppings"]
o1 = request_data["dullness"]
p1 = request_data["reduction_in_the_size_of_the_egg"]
q1 = request_data["Rough_scaly_feathers"]
r1 = request_data["bloated_abdomen"]
s1 = request_data["brittle_bones"]
t1 = request_data["redness_or_scrabs_on_skin"]
Disease = disapi.predisease([a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a1, b1, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, n1, o1, p1, q1, r1, s1, t1])
Data = {"weight_loss":0, "loss_of_appetite": 0, "swollen_joints": 0, "lameness": 0, "nasal_discharge": 0,
"ocular_discharge": 0, "ruffled_feathers": 0, "diarrhea": 0, "mites": 0, "egg_production_decrease": 0,
"inability_to_absorb_nutrients": 0, "distinctive_bumps": 0, "warts": 0, "stunted_growth": 0, "edema_in_the_comb": 0,
"discoloration": 0, "coughing_and_sneezing": 0, "swelling": 0, "rales": 0, "gasping": 0,
"muscular_tremors": 0, "opisthotonus": 0, "Closed_eyes": 0, "facial_swelling": 0, "increased_thirst": 0,
"lethargy": 0, "profuse_tear_secretion": 0, "facial_skin_edema": 0, "progressing_tremors": 0, "drowsy": 0,
"head_droop": 0, "laying_on_ground": 0, "Thick_large_white_patches_on_the_inside_the_mouth_and_crop_areas": 0,
"Crusty_looking_eyes": 0, "hyperemic": 0,
"high_fever": 0, "paralysis": 0, "dehydration": 0, "unkempt_feathers": 0, "yellow_fecal_droppings": 0, "dullness": 0, "reduction_in_the_size_of_the_egg": 0
, "Rough_scaly_feathers": 0, "bloated_abdomen": 0, "brittle_bones": 0, "redness_or_scrabs_on_skin": 0}
for i in Data.keys():
if i in request_data:
Data[i] = 1
else:
Data[i] = 0
Disease = disapi.predisease(list(Data.values()))
print(list(Data.values()))
return jsonify(Disease)
@app.route("/stage", methods=["GET"])
@app.route("/stage", methods=["POST"])
def stage():
#request_data = request.get_json()
request_data = request.get_json()
print (type(request_data))
request_data = str(request_data)
print(type(request_data))
request_data = request_data.replace('{', '')
request_data = request_data.replace('}', '')
request_data = request_data.split(':')
request_data=request_data[1]
print(request_data)
a = request_data["weight_loss"]
b = request_data["loss_of_appetite"]
c = request_data["swollen_joints"]
d = request_data["lameness"]
e = request_data["nasal_discharge"]
f = request_data["ocular_discharge"]
g = request_data["ruffled_feathers"]
h = request_data["diarrhea"]
i = request_data["mites"]
j = request_data["egg_production_decrease"]
k = request_data["inability_to_absorb_nutrients"]
l = request_data["distinctive_bumps"]
m = request_data["warts"]
n = request_data["stunted_growth"]
o = request_data["edema_in_the_comb"]
p = request_data["discoloration"]
q = request_data["coughing_and_sneezing"]
r = request_data["swelling"]
s = request_data["rales"]
t = request_data["gasping"]
u = request_data["muscular_tremors"]
v = request_data["opisthotonus"]
w = request_data["Closed_eyes"]
x = request_data["facial_swelling"]
y = request_data["increased_thirst"]
z = request_data["lethargy"]
a1 = request_data["profuse_tear_secretion"]
b1 = request_data["facial_skin_edema"]
c1 = request_data["progressing_tremors"]
d1 = request_data["drowsy"]
e1 = request_data["head_droop"]
f1 = request_data["laying_on_ground"]
g1 = request_data["Thick_large_white_patches_on_the_inside_the_mouth_and_crop_areas"]
h1 = request_data["Crusty_looking_eyes"]
i1 = request_data["hyperemic"]
j1 = request_data["high_fever"]
k1 = request_data["paralysis"]
l1 = request_data["dehydration"]
m1 = request_data["unkempt_feathers"]
n1 = request_data["yellow_fecal_droppings"]
o1 = request_data["dullness"]
p1 = request_data["reduction_in_the_size_of_the_egg"]
q1 = request_data["Rough_scaly_feathers"]
r1 = request_data["bloated_abdomen"]
s1 = request_data["brittle_bones"]
t1 = request_data["redness_or_scrabs_on_skin"]
Stage = mlapi.predstage([a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, a1, b1, c1, d1, e1, f1, g1, h1, i1, j1, k1, l1, m1, n1, o1, p1, q1, r1, s1, t1])
Data = {"weight_loss":0, "loss_of_appetite": 0, "swollen_joints": 0, "lameness": 0, "nasal_discharge": 0,
"ocular_discharge": 0, "ruffled_feathers": 0, "diarrhea": 0, "mites": 0, "egg_production_decrease": 0,
"inability_to_absorb_nutrients": 0, "distinctive_bumps": 0, "warts": 0, "stunted_growth": 0, "edema_in_the_comb": 0,
"discoloration": 0, "coughing_and_sneezing": 0, "swelling": 0, "rales": 0, "gasping": 0,
"muscular_tremors": 0, "opisthotonus": 0, "Closed_eyes": 0, "facial_swelling": 0, "increased_thirst": 0,
"lethargy": 0, "profuse_tear_secretion": 0, "facial_skin_edema": 0, "progressing_tremors": 0, "drowsy": 0,
"head_droop": 0, "laying_on_ground": 0, "Thick_large_white_patches_on_the_inside_the_mouth_and_crop_areas": 0,
"Crusty_looking_eyes": 0, "hyperemic": 0,
"high_fever": 0, "paralysis": 0, "dehydration": 0, "unkempt_feathers": 0, "yellow_fecal_droppings": 0, "dullness": 0, "reduction_in_the_size_of_the_egg": 0
, "Rough_scaly_feathers": 0, "bloated_abdomen": 0, "brittle_bones": 0, "redness_or_scrabs_on_skin": 0}
for i in Data.keys():
if i in request_data:
print(i)
Data[i] = 1
print(i)
else:
Data[i] = 0
Stage = mlapi.predstage(list(Data.values()))
print(list(Data.values()))
return jsonify(Stage)
@app.route("/medi", methods=["GET"])
@app.route("/medi", methods=["POST"])
def medicine():
request_data = request.get_json()
print(request_data)
a = request_data["prognosis"]
b = request_data["stage"]
Medi = medi.predmed([a, b])
a = request_data["prognosis"]
b = request_data["stage"]
Stage = {'Stage 1':0,'Stage 2':1,'Stage 3':2}
Disease = {'Coccidiosis':0,'Fowl Cholera':1,'Avian Influenza':2,'Fowl Pox':3,'Infectious Bronchitis':4,
'Newcastle disease':5,'Salmonellosis':6,'Infectious Coryza':7,'Mycoplasma':8,'Botulism':9,
'Thrush':10,'Pullorum':11,'Marek’s Disease':12,'Aspergillosis':13,'Histomoniasis':14,
'Egg Drop Syndrome':15,'Infectious Bursal Disease':16,'Rot gut disease':17,
'Northern fowl mites':18,'Right ventricular failure and ascites syndrome':19,
'Osteomalacia':20,'Poultry Lice':21}
Medi = medi.predmed([Disease[a], Stage[b]])
return jsonify(Medi)
if __name__=='__main__':
app.run(debug=True)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment