Skip to content

Commit

Permalink
changed app.py and Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
pritesh2000 committed Jul 31, 2024
1 parent deb8cfa commit 9b4501a
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
FROM python:3.10-slim-buster
FROM python:3.10-slim

RUN apt update -y && apt install awscli -y
WORKDIR /app

COPY . /app
RUN pip install -r requirements.txt

CMD ["python3", "app.py"]
CMD flask run -h 0.0.0.0 -p 8080
15 changes: 10 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from flask import render_template, Flask, request
import os
import numpy as np
import pandas as pd
from mlProject.pipeline.prediction import PredictionPipeline

app = Flask(__name__) #intializing a flask app
Expand All @@ -17,7 +18,6 @@ def run_initial_training():
def homePage():
return render_template("index.html")


@app.route('/train', methods=['GET']) # Route to train pipeline
def training():
global training_done
Expand Down Expand Up @@ -47,9 +47,16 @@ def index():

data = [fixed_acidity,volatile_acidity,citric_acid,residual_sugar,chlorides,free_sulfur_dioxide,total_sulfur_dioxide,density,pH,sulphates,alcohol]
data = np.array(data).reshape(1,11)

# Example feature names (these should match the names used during model training)
feature_names = ['fixed acidity', 'volatile acidity', 'citric acid', 'residual sugar', 'chlorides', 'free sulfur dioxide', 'total sulfur dioxide', 'density', 'pH', 'sulphates', 'alcohol']

# Create a DataFrame with the same feature names
frame = pd.DataFrame(data,
columns=feature_names)

obj = PredictionPipeline()
predict = obj.predict(data)
predict = obj.predict(frame)

return render_template('results.html', prediction = str(predict))

Expand All @@ -61,7 +68,5 @@ def index():
return render_template('index.html')

if __name__ == "__main__":
run_initial_training()
# app.run(host="0.0.0.0", port=7000, debug=False)
# app.run(host="0.0.0.0", port=8080, debug=True)
run_initial_training()
app.run(host="0.0.0.0", port=8080, debug=False)

0 comments on commit 9b4501a

Please sign in to comment.