Skip to content

Commit

Permalink
created image
Browse files Browse the repository at this point in the history
  • Loading branch information
lauragreemko committed Oct 8, 2022
1 parent c96eb6b commit 2f88a47
Show file tree
Hide file tree
Showing 13 changed files with 695 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
10 changes: 10 additions & 0 deletions app/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
FROM python:3.7.13-bullseye
WORKDIR app
ENV FLASK_APP=app.py
ENV FLASK_RUN_HOST 0.0.0.0
COPY requirements.txt requirements.txt
RUN python -m pip install --upgrade pip
RUN python -m pip install -r requirements.txt
COPY . .
EXPOSE 5000
CMD ["python", "app.py"]
24 changes: 24 additions & 0 deletions app/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from flask import Flask, render_template
import pandas as pd
from os import environ
from functions import *

app = app = Flask(__name__)

@app.route("/", methods=['GET'])
def hello():
return render_template('index.html')

# 1. Devolver la predicción de los nuevos datos enviados mediante argumentos en la llamada
@app.route('/predict', methods=['GET'])
def predict():
model = load_models('sentiment_model')
text = get_arguments('text')
df = pd.DataFrame()
df['text'] = [text]
prediction = model.predict(df['text'])
prediction = prediction[0]
return render_template('predict.html', predict=prediction)

if __name__ == '__main__':
app.run(debug = True, host = '0.0.0.0', port=environ.get("PORT", 5000))
9 changes: 9 additions & 0 deletions app/functions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import pickle
from flask import request

def load_models(model_name):
path = 'static/models/' + model_name
return pickle.load(open(path,'rb'))

def get_arguments(arg):
return request.args.get(arg, None)
3 changes: 3 additions & 0 deletions app/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Flask
pandas
sklearn
Binary file added app/static/images/background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/static/images/title.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/static/models/sentiment_model
Binary file not shown.
40 changes: 40 additions & 0 deletions app/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<!doctype html>
<html>

<head>
<title>European Soccer</title>
<meta name="description" content="European Soccer">
<meta name="keywords" content="European Soccer">
<style type="text/css">
body {
display: flex;
flex-direction: column;
align-items: center;
margin: 150px;
padding: 0px;
background-image: url('static/images/background.jpg');
background-size: cover;
}
.form {
display: flex;
flex-direction: column;
padding: 3rem;
}
</style>
</head>

<body>
</body>
<h1 style="color:white;font-family:verdana;">Sentiment analysis</h1>

<div class="forms">
<div class="form">
<h2 style="color:white;font-family:verdana;">Enter your text</h2>
<form method="get" action="/predict" autocomplete="on" >
<input type="text" name="text" /><br/>
<button type="submit">Submit</bsutton>
</form>
</div>
</div>

</html>
30 changes: 30 additions & 0 deletions app/templates/predict.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!doctype html>
<html>

<head>
<title>European Soccer</title>
<meta name="description" content="European Soccer">
<meta name="keywords" content="European Soccer">
<style type="text/css">
body {
display: flex;
flex-direction: column;
align-items: center;
margin: 150px;
padding: 0px;
background-image: url('static/images/background.jpg');
background-size: cover;
}
.form {
display: flex;
flex-direction: column;
padding: 3rem;
}
</style>
</head>

<body>
</body>
<div>{{predict}}</div>
<a href="/">Go Back</a>
</html>
Binary file added data/.DS_Store
Binary file not shown.
179 changes: 179 additions & 0 deletions data/tweets.csv

Large diffs are not rendered by default.

Loading

0 comments on commit 2f88a47

Please sign in to comment.