Refactored to fit the 'largerer flask app' pattern based on flask docs