from flask import Flask,request,render_template import numpy as np import sys from sklearn.preprocessing import StandardScaler from src.exception import CustomException from src.pipeline.predict_pipeline import CustomData,PredictPipeline application = Flask(__name__) app = application ## route for home page @app.route('/') def index(): return render_template('index.html') @app.route('/predictdata',methods=['GET','POST']) def predict_datapoint(): try: if request.method == 'GET': return render_template('index.html') else: data=CustomData( gender=request.form.get('gender'), race_ethnicity=request.form.get('race_ethnicity'), parental_level_of_education=request.form.get('parental_level_of_education'), lunch=request.form.get('lunch'), test_preparation_course=request.form.get('test_preparation_course'), reading_score=request.form.get('reading_score'), writing_score=request.form.get('writing_Score') ) pred_df = data.get_data_as_data_frame() predict_pipeline = PredictPipeline() results = predict_pipeline.predict(pred_df) return render_template('index.html',results=results[0]) except Exception as e: raise CustomException(e,sys) if __name__ == '__main__': app.run(host='0.0.0.0',port=7860)