Skip to content

Commit 6d7cc22

Browse files
committed
working on next blog post
1 parent caf98fe commit 6d7cc22

File tree

2 files changed

+82
-7
lines changed

2 files changed

+82
-7
lines changed

content/posts/170524-bar-charts-bokeh.markdown

+81-7
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,27 @@ but Python 3 is strongly recommended for new applications. In addition
2121
to Python throughout this tutorial we will also use the following
2222
[application dependencies](/application-dependencies.html):
2323

24-
* [Flask](/flask.html) web framework, 0.12
25-
* [Bokeh](/bokeh.html) data visualization library, version 0.12.5
24+
* [Flask](/flask.html) web framework,
25+
[version 0.12.2](https://github.com/pallets/flask/releases/tag/0.12.2)
26+
* [Bokeh](/bokeh.html) data visualization library,
27+
[version 0.12.5](https://github.com/bokeh/bokeh/releases/tag/0.12.5)
2628
* [pandas](/pandas.html) data structures and analysis library,
27-
version 0.20.1
29+
[version 0.20.1](https://github.com/pandas-dev/pandas/releases/tag/v0.20.1)
2830
* [pip](https://pip.pypa.io/en/stable/) and
2931
[virtualenv](https://virtualenv.pypa.io/en/latest/), which come
30-
packaged with Python 3, to install and isolate the Flask and Bokeh
31-
libraries from any other Python projects you might be working on
32+
packaged with Python 3, to install and isolate the Flask, Bokeh,
33+
and pandas libraries from any other Python projects you might be
34+
working on
3235

3336
If you need help getting your
3437
[development environment](/development-environments.html) configured
3538
before running this code, take a look at
3639
[this guide for setting up Python 3 and Flask on Ubuntu 16.04 LTS](/blog/python-3-flask-green-unicorn-ubuntu-1604-xenial-xerus.html)
3740

3841
All code in this blog post is available open source under the MIT license
39-
on GitHub under the blog-code-examples repository. Use it and abuse it
40-
as you like for your own applications.
42+
on GitHub under the
43+
[bar-charts-bokeh-flask-python-3 directory of the blog-code-examples repository](https://github.com/fullstackpython/blog-code-examples).
44+
Use the source code and abuse it as you like for your own applications.
4145

4246

4347
## Installing Bokeh and Flask
@@ -93,3 +97,73 @@ We are going to first code a basic Flask application then add our bar
9397
chart to the rendered page.
9498

9599

100+
`app.py`:
101+
102+
```python
103+
from flask import Flask, render_template
104+
105+
106+
app = Flask(__name__)
107+
108+
109+
@app.route("/<int:bars_count>/")
110+
def chart(bars_count):
111+
return render_template("chart.html", bars_count=bars_count)
112+
113+
114+
if __name__ == "__main__":
115+
app.run(debug=True)
116+
```
117+
118+
...explain code...
119+
120+
`templates/chart.html`:
121+
122+
```
123+
<!DOCTYPE html>
124+
<html>
125+
<head>
126+
<title>Bar charts with Bokeh!</title>
127+
</head>
128+
<body>
129+
<h1>Bugs found over the past {{ bars_count }} days</h1>
130+
</body>
131+
</html>
132+
```
133+
134+
Short explanation of above HTML.
135+
136+
```
137+
$(barchart) python app.py
138+
```
139+
140+
Go to "localhost:5000" in your web browser.
141+
142+
...Screenshots of it working...
143+
144+
145+
## Generating the Bar Chart
146+
147+
148+
149+
## What's next?
150+
Nice work creating a nifty configurable bar chart in Bokeh! Next
151+
up you can modify the color scheme, change the input data source or try
152+
to create other types of charts.
153+
154+
There is a lot more than Bokeh can do, so be sure to check out the
155+
[official project documentation](http://bokeh.pydata.org/en/latest/) ,
156+
[GitHub repository](https://github.com/bokeh/bokeh),
157+
the [Full Stack Python Bokeh page](/bokeh.html) or take a look at
158+
[other topics on Full Stack Python](/table-of-contents.html).
159+
160+
Questions? Let me know via
161+
[a GitHub issue ticket on the Full Stack Python repository](https://github.com/mattmakai/fullstackpython.com/issues),
162+
on Twitter
163+
[@fullstackpython](https://twitter.com/fullstackpython)
164+
or [@mattmakai](https://twitter.com/mattmakai).
165+
166+
See something wrong in this blog post? Fork
167+
[this page's source on GitHub](https://github.com/mattmakai/fullstackpython.com/blob/master/content/posts/170524-bar-charts-bokeh.markdown)
168+
and submit a pull request.
169+

theme/templates/blog/bar-charts-bokeh-flask-python-3.html

+1
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@
55
<a href="/ubuntu.html" class="list-group-item smaller-item">Ubuntu</a>
66
<a href="/wsgi-servers.html" class="list-group-item smaller-item">WSGI Servers</a>
77
<a href="/green-unicorn-gunicorn.html" class="list-group-item smaller-item">Green Unicorn (Gunicorn)</a>
8+
<a href="http://bokeh.pydata.org/en/latest/" class="list-group-item smaller-item">Official Bokeh Docs {% include "blog/external-link.html" %}</a>

0 commit comments

Comments
 (0)