-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c96eb6b
commit 2f88a47
Showing
13 changed files
with
695 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Flask | ||
pandas | ||
sklearn |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.