-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
100 lines (71 loc) · 2.63 KB
/
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
from flask import Flask, render_template, request
from helpers import data_finder
import finnhub
from helpers import *
from helpers import display_stock, request_list, request_index
# Client setup
finnhub_client = finnhub.Client(api_key="c67jj0qad3iai8rb0ht0")
app: Flask = Flask(__name__)
@app.route("/", methods=["GET", "POST"])
async def index():
global stock
global stocks
global request_index
global request_list
if request.method == "POST":
global stock_table_link
global html_stock_table_link
global display_stock
finnhub_client = finnhub.Client(api_key="c67jj0qad3iai8rb0ht0")
stock = request.form['stock']
print(stock)
data_finder(stock)
if stock == '':
return(render_template("index.html"))
return render_template('index.html', stock=stock)
else:
global request_list
global request_index
request_index = -1
request_list.clear()
print('restart button activated')
print(request_list)
return render_template('index.html', stock=stock, request_list = request_list)
@app.route("/my-list", methods=["GET", "POST"])
async def my_list():
global stocks
global display_stock
global request_list
global request_index
global request_index_list
if request.method == "POST":
return render_template('stock_table.html', request_list = request_list, display_stock = display_stock, stocks = stocks)
else:
while len(request_list) < 6:
request_list.append(request_list[len(request_list) - 1])
return render_template("my-list.html", request_list = request_list, display_stock = display_stock, stocks = stocks)
@app.route("/my-list/stock_1", methods=['GET'])
async def stock_1():
data_finder(request_list[0][0])
return render_template("stock_table.html")
@app.route("/my-list/stock_2", methods=['GET'])
async def stock_2():
data_finder(request_list[1][0])
return render_template("stock_table.html")
@app.route("/my-list/stock_3", methods=['GET'])
async def stock_3():
data_finder(request_list[2][0])
return render_template("stock_table.html")
@app.route("/my-list/stock_4", methods=['GET'])
async def stock_4():
data_finder(request_list[3][0])
return render_template("stock_table.html")
@app.route("/my-list/stock_5", methods=['GET'])
async def stock_5():
data_finder(request_list[4][0])
return render_template("stock_table.html")
@app.route("/stock_table", methods=["GET"])
async def stock_table():
return render_template("stock_table.html")
if __name__ == '__main__':
app.run(debug=True)