forked from thedataincubator/flask-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
28 lines (19 loc) · 715 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
"""Display a stock ticker visualization based on user input."""
from flask import Flask, render_template, request, redirect
app = Flask(__name__)
@app.route('/', methods=('GET', 'POST'))
def index():
"""Render the app's main page."""
if request.method == 'GET':
# Default gives IBM's ticker when first loaded.
symbol = 'IBM'
return render_template('index.html', symbol=symbol)
else:
# User submitted a ticker symbol aka method = 'POST'
symbol = request.form['symbol']
return render_template('index.html', symbol=symbol)
@app.route('/about')
def about():
return render_template('about.html')
if __name__ == '__main__':
app.run(port=33507)