-
Set Flask_APP=budget.py, flask run
-
Using Flask-restful and bootstrap 4.1
-
API key (or token) must be loaded into session before using the api. A link to load a key will be displayed. It's not really necessary, but I wanted to add it, and didn't want to put it on every request. None of the API or saving and loading data will work without it.
-
Saved data to file for ease of testing. Left hand side has controls to let you load data from a file, along with save changes to data. The link to load data will only display if no categories exist. You will have to delete them all if you want to reload from file. Save will save all of the current data to a file, overwriting whatever is there. The saved data is stored as a pickle.
-
Api routes for get are:
Categories: '/c', '/api/cats', '/api/cats/<int:cat>'
Transactions: '/t', '/api/transactions', '/api/transactions/<int:transaction>', '/api/transactions/<int:transaction>&value=<val>
-
Console will show all the AJAX requests.
-
Buttons run AJAX to the rest API, except the last button because I didn't want it that way.
-
Color is generated by a hash of innerHTML. If AJAX is a success the recolor function is called, so the color will change (if html changes).
-
Analysis page runs a minimum version of the ajax, just to get JSON of the data. Delay of one second is applied to ensure ajax completes before analyzing. The functions could be moved to the ajax calls themselves, but I preferred to have them lowly coupled.