Right before the NBA season began, I laid out my predictions for how many wins each team would achieve this season. To track the progress of these predictions as well as the overall NBA rankings, I planned to blog on a weekly basis. While I could have gone with a standard WordPress blog (like this one) I wanted to easily run and access Python code. To do that, I created a blog with Flask: MNBA.
Flask is “is a microframework for Python”. It is my favorite way to integrate Python into a website. The tutorial they offer, Flaskr, is the creation of a mini-blog. So setting up the foundations of my website MNBA was essentially an adaptation of that tutorial. For the hosting of my site I use PythonAnywhere.com, which is cheap and they do a great job of hosting Flask-based websites. The layout was a publicly available template using the Pure.css style.
I have a Python script that runs each week to pull current data about NBA teams (such as wins, losses, points scored, and points allowed), runs some simple calculations (to get my desired statistics such as Pythogrean wins expected) and writes this data to a MySQL database. Then I use Matplotlib to graph recent changes in expected wins. I do a short writeup of my thoughts on whatever is going on in the NBA as well as a table view of the MySQL data for that week.
I have created a few other Flask sites I plan to write about in the future. While there was a bit of a learning curve because it is different from a simple Python script on your computer, after some experience with Flask it is easy to get a new site up and running.