-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
30 lines (21 loc) · 793 Bytes
/
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
import os
from flask import Flask, render_template, request
from src.pipelines.model_predictor import ModelPredictoripeline
app = Flask(__name__)
@app.route("/", methods=["GET"])
def home():
return render_template("index.html")
@app.route("/train", methods=["GET"])
def train():
os.system("python main.py")
return "Training Succesful"
@app.route("/", methods=["POST", "GET"])
def predict():
result = None
model_predictor_pipeline = ModelPredictoripeline()
data = request.form["review"]
result = "Positive" if model_predictor_pipeline.run(data=data) == 1 else "Negative"
return render_template("index.html", data=data, result=result)
if __name__ == "__main__":
# app.run(host="0.0.0.0", port=8080, debug=True)
app.run(host="0.0.0.0", port=8080)