-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication.py
More file actions
39 lines (32 loc) · 1.26 KB
/
application.py
File metadata and controls
39 lines (32 loc) · 1.26 KB
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
31
32
33
34
35
36
37
38
39
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 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_prepration_course=request.form.get('test preparation course'),
reading_score=float(request.form.get('reading score')),
writing_score=float(request.form.get('writing score'))
)
pred_df = data.get_data_as_data_frame()
print(pred_df)
predict_pipeline = PredictPipeline()
result = predict_pipeline.predict(pred_df)
return render_template('home.html', results=result[0])
if __name__=='__main__':
app.run(host="0.0.0.0")