From 6aef81c562b2b214dacbc1a221f292aea7019f64 Mon Sep 17 00:00:00 2001 From: Matt Chan Date: Sat, 27 Jun 2020 16:37:24 -0700 Subject: [PATCH] Finishing touches. --- README.md | 50 +++++++++++------------------------------- app.py | 16 +++++++++++++- conda-requirements.txt | 7 ------ templates/about.html | 15 ++++++++++++- templates/index.html | 13 +++++++++++ ticker.py | 18 ++++++++++++++- 6 files changed, 72 insertions(+), 47 deletions(-) delete mode 100644 conda-requirements.txt diff --git a/README.md b/README.md index e4b472cc7..6a2daf32b 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,17 @@ -# Flask on Heroku +# A Simple Stock Ticker Visualization App -This project is intended to help you tie together some important concepts and -technologies from the 12-day course, including Git, Flask, JSON, Pandas, -Requests, Heroku, and Bokeh for visualization. +Hello! This little stock ticker visualization web app was created by [Matt Chan](http://github.com/thewchan/) as part of his adventure over the [The Data Incubator Data Science Fellowship](https://www.thedataincubator.com). This app was the on-boarding assignment prior to the beginning of the actual fellowship program. Check out the source code of the app here at Github, and see it live over at [Heroku](https://mychan-stock.herokuapp.com/)! Some skeleton file and code were provided by TDI themselves. The interactive visualization is powered by [Bokeh](https://bokeh.org/), an open source interactive visualization Python library. The stock price time series data is provided by [Alpha Vantage](https://www.alphavantage.co/), who provides free APIs for financial trends. The website itself is powered by [Flask](https://flask.palletsprojects.com/en/1.1.x/), a micro web framework written in Python which is in turn powered by [Jinja](https://palletsprojects.com/p/jinja/) and [Werkzeug](https://werkzeug.palletsprojects.com/en/1.0.x/), a template engine and a web server gateway interface toolkit, respectively. The CSS of the web app is powered by [Pure.css](https://purecss.io/), a set of CSS modules designed by [Yahoo](https://www.yahoo.com/), with minor modification. The favicon was provided by [Free Favicon](https://freefavicon.com/). Enjoy! -The repository contains a basic template for a Flask configuration that will -work on Heroku. +####Licence +A Simple Stock Ticker Visualization Web App +Copyright (C) 2020 Matthew Chan -A [finished example](https://lemurian.herokuapp.com) that demonstrates some basic functionality. +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. -## Step 1: Setup and deploy -- Git clone the existing template repository. -- `Procfile`, `requirements.txt`, `conda-requirements.txt`, and `runtime.txt` - contain some default settings. -- There is some boilerplate HTML in `templates/` -- Create Heroku application with `heroku create ` or leave blank to - auto-generate a name. -- (Suggested) Use the [conda buildpack](https://github.com/thedataincubator/conda-buildpack). - If you choose not to, put all requirements into `requirements.txt` - - `heroku config:add BUILDPACK_URL=https://github.com/thedataincubator/conda-buildpack.git#py3` - - The advantages of conda include easier virtual environment management and fast package installation from binaries (as compared to the compilation that pip-installed packages sometimes require). - One disadvantage is that binaries take up a lot of memory, and the slug pushed to Heroku is limited to 300 MB. Another note is that the conda buildpack is being deprecated in favor of a Docker solution (see [docker branch](https://github.com/thedataincubator/flask-framework/tree/docker) of this repo for an example). -- Deploy to Heroku: `git push heroku master` -- You should be able to see your site at `https://.herokuapp.com` -- A useful reference is the Heroku [quickstart guide](https://devcenter.heroku.com/articles/getting-started-with-python-o). - -## Step 2: Get data from API and put it in pandas -- Use the `requests` library to grab some data from a public API. This will - often be in JSON format, in which case `simplejson` will be useful. -- Build in some interactivity by having the user submit a form which determines which data is requested. -- Create a `pandas` dataframe with the data. - -## Step 3: Use Bokeh to plot pandas data -- Create a Bokeh plot from the dataframe. -- Consult the Bokeh [documentation](http://bokeh.pydata.org/en/latest/docs/user_guide/embed.html) - and [examples](https://github.com/bokeh/bokeh/tree/master/examples/embed). -- Make the plot visible on your website through embedded HTML or other methods - this is where Flask comes in to manage the interactivity and display the desired content. -- Some good references for Flask: [This article](https://realpython.com/blog/python/python-web-applications-with-flask-part-i/), especially the links in "Starting off", and [this tutorial](https://github.com/bev-a-tron/MyFlaskTutorial). +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. \ No newline at end of file diff --git a/app.py b/app.py index d8f372caa..6b6362673 100644 --- a/app.py +++ b/app.py @@ -1,4 +1,18 @@ -"""Display a stock ticker visualization based on user input.""" +"""Display a stock ticker visualization based on user input. + +A Simple Stock Ticker Visualization Web App +Copyright (C) 2020 Matthew Chan + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. +""" import json import os from flask import Flask, render_template, request, send_from_directory diff --git a/conda-requirements.txt b/conda-requirements.txt deleted file mode 100644 index fe34ad196..000000000 --- a/conda-requirements.txt +++ /dev/null @@ -1,7 +0,0 @@ -pandas -bokeh -dill -flask -jinja2 -pip -simplejson diff --git a/templates/about.html b/templates/about.html index f8d241536..a86a51413 100644 --- a/templates/about.html +++ b/templates/about.html @@ -1,3 +1,16 @@ + + @@ -17,7 +30,7 @@

About

- Hello! This little stock ticker visualization web app was created by as part of his adventure over the The Data Incubator Data Science Fellowship. This app was the on-boarding assignment prior to the beginning of the actual fellowship program. Check out the source code of the app here! Some skeleton file and code were provided by TDI themselves. The interactive visualization is powered by Bokeh, an open source interactive visualization Python library. The stock price time series data is provided by Alpha Vantage, who provides free API for financial trends. The CSS of the web app is powered by Pure.css, a set of CSS modules designed by Yahoo, with minor modification. Enjoy! + Hello! This little stock ticker visualization web app was created by as part of his adventure over the The Data Incubator Data Science Fellowship. This app was the on-boarding assignment prior to the beginning of the actual fellowship program. Check out the source code of the app here! This app is hosted by Heroku. Some skeleton file and code were provided by TDI themselves. The interactive visualization is powered by Bokeh, an open source interactive visualization Python library. The stock price time series data is provided by Alpha Vantage, who provides free APIs for financial trends. The website itself is powered by Flask, a micro web framework written in Python which is in turn powered by Jinja and Werkzeug, a template engine and a web server gateway interface toolkit, respectively. The CSS of the web app is powered by Pure.css, a set of CSS modules designed by Yahoo, with minor modification. The favicon was provided by Free Favicon. Enjoy!

diff --git a/templates/index.html b/templates/index.html index dcfc9944c..9abc45100 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,3 +1,16 @@ + + diff --git a/ticker.py b/ticker.py index e7d9ebb2e..a4b229686 100644 --- a/ticker.py +++ b/ticker.py @@ -1,4 +1,20 @@ -"""Render the bokeh visualization of the stock time series.""" +"""Render the bokeh visualization of the stock time series. + +Display a stock ticker visualization based on user input. + +A Simple Stock Ticker Visualization Web App +Copyright (C) 2020 Matthew Chan + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. +""" import json import pandas as pd import requests