forked from thedataincubator/flask-framework
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
30 lines (21 loc) · 816 Bytes
/
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
from flask import Flask, render_template, request, redirect
from quandl_py_direct import get_stock_price, insert_plot_into_html
import os
app = Flask(__name__)
@app.route('/')
def main():
return redirect('/index')
@app.route('/index')
def index():
return render_template('index.html')
@app.route('/plot', methods=['POST'])
def plot():
stock_symbol = request.form['myvar'].upper()
get_stock_price(stock_symbol)
orig_template="index.html"
output_html="plot.html"
insert_plot_into_html(os.path.join("templates","index.html"), os.path.join("templates","lines.html"), os.path.join("templates","plot.html")) #must be called after get_stock_price()
return render_template('plot.html')
if __name__ == '__main__':
app.config.update(TEMPLATES_AUTO_RELOAD=True)
app.run(port=33507)