-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9b3e741
commit e3ef80f
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,47 @@ | ||
|
||
from flask import Flask,request,render_template | ||
import numpy as np | ||
import pandas as pd | ||
|
||
from sklearn.preprocessing import StandardScaler | ||
from src.pipeline.predict_pipeline import CustomData,PredictPipeline | ||
|
||
|
||
application=Flask(__name__) | ||
|
||
app=application | ||
|
||
## Route for a home page | ||
|
||
@app.route('/') | ||
def index(): | ||
return render_template('index.html') | ||
|
||
@app.route('/predictdata',methods=['GET','POST']) | ||
def predict_datapoint(): | ||
if request.method=='GET': | ||
return render_template('home.html') | ||
else: | ||
data=CustomData( | ||
gender=request.form.get('gender'), | ||
race_ethnicity=request.form.get('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=float(request.form.get('writing_score')), | ||
writing_score=float(request.form.get('reading_score')) | ||
|
||
) | ||
pred_df=data.get_data_as_data_frame() | ||
print(pred_df) | ||
print("Before Prediction") | ||
|
||
predict_pipeline=PredictPipeline() | ||
print("Mid Prediction") | ||
results=predict_pipeline.predict(pred_df) | ||
print("after Prediction") | ||
return render_template('home.html',results=results[0]) | ||
|
||
|
||
if __name__=="__main__": | ||
app.run(host="0.0.0.0") |