This project attempts to build a suite of simple web apps.
In Windows, simply run in any cmd or cmder prompt:
> start_flask
selector
randomly selects songs from a Google Sheet.
This app has a few main ideas:
- loading the page (
GET
) auto retrives data from a default url. It then locally writes two files: songs and shuffled dataset - optionally select a data to override the default dataset (read a url or file)
- pushing the button (
POST
) selects from the shuffled data and removes the selection. This file rebuilds a shuffled dataset when it is depleted. The refresh button also rebuilds the shuffled dataset.
The selector
app can read data from Google Sheets (given a url) or from a selected file (.txt
or .csv
). Google Sheets must be published and the url to the .csv
file must be used. If neither option is provided, a default Sheets url is used, which is saved in a private config file.
NOTE: although modifications to Google Sheets are saved instantaneously, changes are delayed to the Published
url. Wait about 5 minutes to see resulting modifications in the app. For improved lag, modify and upload a local file.
DEPRECATED: the uploading files data option proved overly complex. If uploading a file is needed, upload to Google Docs and use the url data option.
- data is only read as DataFrames from Google sheets; it is thereafter written and read locally as
.csv
files (e.g.db_*
files). db_*
files are temporary, psuedo-"databases"; they are written to preserve persisted data between page loads and button presses and act as a substitute to actual databases._viz/
: something that is lacking from many web app tutorials are pictures or visual CI of code. This (non-versioned) folder captures the progress of this project.
pre
: cli tool, read from text/csv files and Google Sheets0.1.0
: structure, selector tool0.2.0
: visual update, navbar, make file0.2.1
: jquery, collapsible divs0.2.2
: refactor/symlinkrandom_select_
, dynamic table, startup script, reload data via refresh,models.py
0.3.0
: read as DataFrames, local csv persistent files (deprecate global variables), refresh to reshuffle data0.3.1
: data options (url), deprecate upload data option1.0.0
: fromworkflowtools
, add dynamic refresh button1.0.1
: published on GitHub, new versioning1.0.2
: add tests, release branch to master
Set environments and run the following in commandline:
> cd l/_projects/<app_folder>
> source activate lab
In Windows (cmd)
> set FLASK_APP=app.py
> flask run
or Linux (bash)
> export FLASK_APP=app.py
> FLASK_APP=app.py flask run
Use debug
mode in a development env to avoid restarting the server:
> set FLASK_ENV=development
The Windows dev commands are automated in the start_flask.bat
file.
Just run:
> nosetests
This should run unit tests and textfixtures.
- Adapted from PyBites 100 Days of Code
- Adapted from CS50's Web Dev with Python Course, site
- Visually cleaned and extended from Traversy Media tutorial
- Visuals built on Bootstrap CDN and starter template
- Basic tutorial by w3schools.com
- Flask docs on uploading
- Post on Refresh Button
- Docs on favicons
- Tutorial on deployment with pythonanywhere