Showing Internal Server Error in flask python
from prettytable import PrettyTable
from flask import Flask, request
app = Flask(__name__)
@app.route("/", methods=["GET", "POST"])
class Structure_Cal:
def __init__(self, Slope, Texture,Soil_depth,Catchment_area,Land_use):
self.slope=Slope
self.texture=Texture
self.soil_depth=Soil_depth
self.catchment_area=Catchment_area
self.land_use=Land_use
def sturcture_defined(self, index):
stucture_def=['Field bunding with waste weir','Outlet structure (grassed turfing or stone pitching)',
'Masonry mini drop (outlet)','On Farm lined pond (small)','On Farm unlined pond (small)',
'Farm pond (big) IFS' ,'Staggered trench','Field boundary trench-cum-bund','Staggered trench',
'Diversion drain with WHS','contour stone bunding','recharge pit','contour stone bunding',
'Vegetative and live check dams','loose boulder check dams','earthern check dams with surplus weir',
'Gabion structure','Percolation tanks with dug well ','Stream bank protection measures','WHS',
'MasonryCheck dam/drop inlet structure','Stream bank protection measures' ]
return stucture_def[index]
def strcuture_calculation(self):
""" This is the function that
calcualte the Strcture with the value
of slope, soil_depth, catchment_area,
land_use user values
"""
### For the first one ####
if (int(self.slope) in range(3, 6) and self.texture=='Any soil'
and int(self.soil_depth) in range(50,101) and self.catchment_area ==0 and self.land_use=='Arable Upland'):
idf=0
fin_struct=self.sturcture_defined(idf)
elif (int(self.slope) in range(1, 4) and self.texture=='Any soil'
and int(self.soil_depth) in range(1,101) and self.catchment_area ==1 and self.land_use=='Arable Medium land'):
idf=1
fin_struct=self.sturcture_defined(idf)
return fin_struct
###### Testing ###########
if __name__ == '__main__':
if request.method == "POST":
Slope = request.form["ENTER THE VALUE"]
Texture=input('Enter Texture Value:')
Soil_depth=int(input('Enter Slope-Depth Value:'))
Catchment_area=int(input('Enter Catchment-area Value:'))
Land_use=input('Enter Land-use Value:')
########
Struture=Structure_Cal(Slope,Texture,Soil_depth,Catchment_area,Land_use)
F_Structure=Struture.strcuture_calculation()
######## Output #########
data_output=PrettyTable(['Slope','Texture','Soil_depth','Catchment_area','Land_use','Structure_Output'])
data_output.add_row([Slope,Texture,Soil_depth,Catchment_area,Land_use,F_Structure])
### Output to Excel
with open('structure_output_final.csv', 'w', newline='') as f_output:
f_output.write(data_output.get_csv_string())
app.run()
####
print(data_output)
What I have tried:
Showing Internal Server Error in flask python