-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
55 lines (48 loc) · 1.62 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
from flask import session, Flask, render_template, request
import os
import random
from flask_wtf import FlaskForm
from wtforms.fields.html5 import IntegerRangeField
from wtforms import SubmitField
from static.py.nameGenerator import genStockTicker
from static.model.chartGenerator import generateStockPrice
class Starting_chart(FlaskForm):
days = IntegerRangeField('Candle', default = 15)
submit = SubmitField('Generate Chart')
app = Flask(__name__,
static_url_path='/static',
static_folder='static',
template_folder='templates')
app.config['SECRET_KEY'] = 'aicstockchartfin'
@app.route('/', methods = ["GET", "POST"])
def home():
form = Starting_chart()
# print (form.validate_on_submit())
if (form.is_submitted()):
start = 1
pre_chart = request.form['days']
# print ("submitted")
ticker = genStockTicker()
generateStockPrice (int(pre_chart),
random.randint(0, 1e3))
return render_template(
'index.html',
form = form,
stock_ticker = ticker,
start = True,
starting_days = pre_chart,
name=session.get('name')
)
else:
return render_template(
'index.html',
form = form,
stock_ticker = '$TICKER',
start = False,
starting_days = 0,
name=session.get('name')
)
if __name__ == '__main__':
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)
# app.run(port=1223)