-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
63 lines (54 loc) · 2.64 KB
/
app.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from flask import Flask, request, render_template
from flask_cors import cross_origin,CORS
import pandas as pd
from backorder.ml.model.esitmator import BackorderData
from backorder.pipeline.prediciton_pipeline import PredictionPipeline
app = Flask(__name__)
cors = CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'
prediction_pipeline = PredictionPipeline()
@app.route("/")
@cross_origin()
def home():
return render_template("index.html")
@app.route("/predict", methods = ["GET", "POST"])
@cross_origin()
def predict():
if request.method == "POST":
national_inv= float(request.form['national_inv'])
lead_time=float(request.form['lead_time'])
in_transit_qty= float(request.form['in_transit_qty'])
forecast_6_month= float(request.form['forecast_6_month'])
sales_6_month = float(request.form['sales_6_month'])
min_bank= float(request.form['min_bank'])
potential_issue= request.form['potential_issue']
pieces_past_due= float(request.form['pieces_past_due'])
perf_6_month_avg= float(request.form['perf_6_month_avg'])
local_bo_qty=float(request.form['local_bo_qty'])
deck_risk=request.form['deck_risk']
oe_constraint=request.form['oe_constraint']
ppap_risk=request.form['ppap_risk']
stop_auto_buy=request.form['stop_auto_buy']
rev_stop=request.form['rev_stop']
backorder_data= BackorderData(national_inv= national_inv,
lead_time=lead_time,
in_transit_qty=in_transit_qty,
forecast_6_month=forecast_6_month,
sales_6_month=sales_6_month,
min_bank=min_bank,
potential_issue=potential_issue,
pieces_past_due=pieces_past_due,
perf_6_month_avg=perf_6_month_avg,
local_bo_qty=local_bo_qty,
deck_risk=deck_risk,
oe_constraint=oe_constraint,
ppap_risk=ppap_risk,
stop_auto_buy=stop_auto_buy,
rev_stop=rev_stop,
)
input_df = backorder_data.get_backorder_input_data_frame()
output = prediction_pipeline.start_single_instance_prediction(dataframe= input_df)
return render_template('index.html',prediction_text=f'{output}')
# return render_template("home1.html")
if __name__ == "__main__":
app.run(port = 5000)