Skip to content

Commit

Permalink
Added interactivity, bascially working.
Browse files Browse the repository at this point in the history
  • Loading branch information
thewchan committed Jun 26, 2020
1 parent c5759f0 commit 9c9aa6e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
11 changes: 9 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""Display a stock ticker visualization based on user input."""
import json
from flask import Flask, render_template, request, redirect
import os
from flask import Flask, render_template, request, send_from_directory
from bokeh.embed import json_item
from bokeh.resources import CDN
from ticker import ticker


Expand Down Expand Up @@ -47,5 +47,12 @@ def plot():
return json.dumps(json_item(p, 'myplot'))


@app.route('/favicon.ico')
def favicon():
"""Redirect to favicon."""
return send_from_directory(os.path.join(app.root_path, 'static'),
'favicon.ico')


if __name__ == '__main__':
app.run(port=33507)
Binary file added static/favicon.ico
Binary file not shown.
5 changes: 4 additions & 1 deletion templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
<html lang="en">
<head>
<meta charset="utf-8">
<link rel="shortcut icon" href="{{ url_for('static', filename='favicon.ico') }}">
<link rel="icon" type="image/gif" href="{{ url_for('static', filename='favicon.ico') }}">
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-2.1.0.min.js" integrity="sha384-YobFyzPeVUsFQydHkJGsJL1kyfHnWxOlPc3EwaV22TmBaeGoXHLWx5aRRVPS9xlE" crossorigin="anonymous">
</script><script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.1.0.min.js" integrity="sha384-NuAg9+TcTQQqvQCTtkCneRrpkTiMhhfiq0KHiBzx8ECiKiLWXHN6i6ia3q7b3eHu" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.1.0.min.js" integrity="sha384-uMVqQc8JqHitD67bXTn9a06Mrk3EiHRaZ18EJENQenAKJ/KL71SakdXYomZQpGRr" crossorigin="anonymous"></script>
Expand All @@ -13,7 +15,7 @@
<div class="row">
<div class="col-lg-12 text-left">
<h2>A Simple Stock Price Visualizer</h2>
<form>
<form id="symbol_input" method="post" action="/">
<label for="symbol">Stock ticker symbol:</label>
<input type="text" id="symbol" name="symbol">
<input type="submit" value="Submit">
Expand All @@ -22,6 +24,7 @@ <h2>A Simple Stock Price Visualizer</h2>
</div>
</div>
<div id="myplot"></div>
<p>{{ symbol }}</p>
<script>
fetch('/plot')
.then(function(response) { return response.json(); })
Expand Down

0 comments on commit 9c9aa6e

Please sign in to comment.