Intro to Flask & Data Science in Sports


What is a "microframework"?
- Receive an HTTP request at a URL route
- Handle the HTTP request with a controller
- Return an HTTP response from that controller
"Out-of-the-box" we can only:
What's missing?
- Object Relational Mapper
- User Account Management
- User Authentication
- Database Migrations
- Forms
- Templating Engine
- Security (CORS, CSRF, etc...)
Lots of important features!
So, why Flask?
"Cream of the Crop"
Independently-developed solutions rise to top...
- Object Relational Mapper => SQLAlchemy
- User Account Management => Flask-admin
- User Authentication => Flask-login
- Database Migrations => Alembic
- Forms => WTForms
- Templating Engine => Jinja2
- Security (CORS, CSRF, etc...) => Flask-CORS...
"Hello World"
from flask import Flask
# Instantiate our app...
app = Flask(__name__)
# We define our URL route, controller to handle requests
@app.route('/')
def hello_world():
return '<h1>Hello World</h1>'
if __name__ == "__main__":
app.run()
- Frequency of new web-dev projects == low
- Speed of Flask "Hello World" dev == fast
"A la Carte Extensions"
- flask_sqlalchemy
- flask_restless
- flask_login
- flask_cors
- flask_admin
"Blueprints"
Modularization and Encapsulation
- Models
- Controllers
- Templates
- Routes
Why not Flask?
- Many ways to solve one problem => Poor Maintainability
- Non-centralized Documentation => More Google Searches
- 136k Django vs. 15k Flask Questions on SO => Smaller Community
Best Use Case:
API Services
Specifically for SPAs (single-page applications)
Data Science in Professional Sports
"Player Tracking" Timeline
- Sydney, Australia olympics (2000)
- Rugby, Soccer, Catapult Technologies
- NBA begins using SportVU (2006)
- NFL begins using Zebra Technologies (2015)
Other Areas of Interest
- Sleep Tracking
- Rise, Jawbone, Readiband, Whoop
- Nutrition and Genetics
- Athletigen, InsideTracker
- Data Aggregation & Reporting Platforms
- Kinduct (Intel's gamble)
- Edge10 (IBM's gamble)
The other 90% of my job...
- Data
- Scouting Evaluations
- Player Physical Measurables
- Player Stats
- Injury History
- Applications
- Data Warehousing
- Machine Learning
- Visualizations
Intro to Flask
By seanharr11
Intro to Flask
- 944