This is a small demo Flask application, almost entirely based on the official Flask tutorial. If you are curious about a piece of non-Looker-specific code or a design decision, refer to the tutorial for full explanations.
This example is likely not suitable for repurposing to production use cases (Flask is not great in production without tweaks), but it is a very easy way to begin working with and understanding the Looker Python SDK in a real-world application.
- Clone this entire repository and
cd sdk-codegen/examples/python/lookersdk-flask
- Recommended: Set up a virtual environment. I use virtualenv:
virtualenv venv && source venv/bin/activate
. - Rename
looker.ini.sample
tolooker.ini
and fill in your credentials OR set environment variables (see Python SDK docs for more). - Make a mental note to not check
looker.ini
into source control, ever. - Run the following commands to set Flask environment variables.
export FLASK_APP=app
andexport FLASK_ENV=development
. - Install required libraries by running
pip install -r requirements.txt
. - Initialize the database by running
flask init-db
. - Start the app by running
flask run
. - Have fun!
This is an intentionally "incomplete" application that has room to grow! Often the best way to learn is to dig in and implement new functionality. If you also learn best by doing, try some of these ideas to get you started exploring:
- Allow a user to select between visualization or table when creating a new post.
- What happens if a user creates a post with a broken Look?
- Why is it so slow to create a new post? Or to just load the /create page in the first place?
- Allow a user to view the Looks and Dashboards they've Favorited in Looker, in the app.
- Harder: What would it take to add appropriate Looker permissions to this app?
- Sky's the limit :)