-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created flask web app and docker container for it
- Loading branch information
1 parent
93076cc
commit 38b7674
Showing
6 changed files
with
126 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,13 @@ | ||
FROM python:3-slim | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
|
||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
ENV FLASK_APP=app.py | ||
|
||
EXPOSE 5000 | ||
|
||
CMD ["flask", "run", "--host=0.0.0.0"] |
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,18 @@ | ||
from flask import Flask, render_template, request | ||
import yfinance as yf | ||
|
||
app = Flask(__name__) | ||
|
||
|
||
@app.route('/', methods=['GET', 'POST']) | ||
def index(): | ||
if request.method == 'POST': | ||
ticker = request.form['ticker'] | ||
stock = yf.Ticker(ticker) | ||
df = stock.history(period='max') | ||
return render_template('index.html', ticker=ticker, data=df.to_html(classes='table table-striped')) | ||
return render_template('index.html') | ||
|
||
|
||
if __name__ == '__main__': | ||
app.run(debug=False) |
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,2 @@ | ||
yfinance | ||
flask |
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,63 @@ | ||
* { | ||
box-sizing: border-box; | ||
} | ||
|
||
body { | ||
margin: 0; | ||
padding: 0; | ||
font-family: Arial, sans-serif; | ||
} | ||
|
||
.container { | ||
width: 80%; | ||
margin: 0 auto; | ||
padding: 20px; | ||
} | ||
|
||
h1, | ||
h2 { | ||
text-align: center; | ||
} | ||
|
||
form { | ||
margin: 20px 0; | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
label { | ||
margin-right: 10px; | ||
} | ||
|
||
input[type="text"] { | ||
padding: 10px; | ||
font-size: 16px; | ||
border: none; | ||
border-radius: 5px; | ||
} | ||
|
||
button[type="submit"] { | ||
padding: 10px 20px; | ||
background-color: #4caf50; | ||
color: white; | ||
border: none; | ||
border-radius: 5px; | ||
cursor: pointer; | ||
} | ||
|
||
button[type="submit"]:hover { | ||
background-color: #3e8e41; | ||
} | ||
|
||
.graph-container { | ||
margin-top: 20px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
} | ||
|
||
.table-container { | ||
margin-top: 20px; | ||
} |
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>Stock Price Graph</title> | ||
<link | ||
rel="stylesheet" | ||
href="{{ url_for('static', filename='style.css') }}" | ||
/> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>Stock Price Graph</h1> | ||
<form method="post"> | ||
<label for="ticker">Enter Ticker Symbol:</label> | ||
<input type="text" id="ticker" name="ticker" required /> | ||
<button type="submit">Submit</button> | ||
</form> | ||
{% if ticker %} | ||
<div class="graph-container"> | ||
<img | ||
src="https://finviz.com/chart.ashx?t={{ ticker }}&ty=c&ta=1&p=d&s=l" | ||
alt="Price Graph for {{ ticker }}" | ||
/> | ||
</div> | ||
<h2>{{ ticker }} Price History</h2> | ||
<div class="table-container">{{ data|safe }}</div> | ||
{% endif %} | ||
</div> | ||
</body> | ||
</html> |