To help simplify the data flow of our application, we determined it would be useful to extract JSON related logic into separate endpoints with a /api prefix in the flask app. The reason for this refactor is because our existing endpoints have a lot of branching logic which can get a bit confusing and harder to maintain. Instead of having a top level if statement inside each endpoint, we have one separate endpoint related to the flask templates / form postbacks, and then a separate /api endpoint for json data.
To help simplify the data flow of our application, we determined it would be useful to extract JSON related logic into separate endpoints with a /api prefix in the flask app. The reason for this refactor is because our existing endpoints have a lot of branching logic which can get a bit confusing and harder to maintain. Instead of having a top level if statement inside each endpoint, we have one separate endpoint related to the flask templates / form postbacks, and then a separate /api endpoint for json data.