-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
54 lines (36 loc) · 1.46 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
from flask import Flask, render_template, jsonify, request, send_file
from src.exception import CustomException
from src.logger import logging as lg
import os,sys
from src.pipeline.train_pipeline import TraininingPipeline
from src.pipeline.predict_pipeline import PredictionPipeline
app = Flask(__name__)
@app.route("/")
def home():
return "Welcome to my application"
@app.route("/train")
def train_route():
try:
train_pipeline = TraininingPipeline()
train_pipeline.run_pipeline()
return "Training Completed!"
except Exception as e:
raise CustomException(e,sys)
@app.route('/predict', methods=['POST', 'GET'])
def upload():
try:
if request.method == 'POST':
# it is a object of prediction pipeline
prediction_pipeline = PredictionPipeline(request)
#now we are running this run pipeline method
prediction_file_detail = prediction_pipeline.run_pipeline()
lg.info("prediction completed. Downloading prediction file.")
return send_file(prediction_file_detail.prediction_file_path,
download_name= prediction_file_detail.prediction_file_name,
as_attachment= True)
else:
return render_template('upload_file.html')
except Exception as e:
raise CustomException(e,sys)
if __name__ == "__main__":
app.run(host="0.0.0.0", port=5000, debug= True)