pacificclimate / scip-backend

Backend that serves salmon population data to the scip webpage
GNU Affero General Public License v3.0
0 stars 0 forks source link

Update usage of Flask #4

Open rod-glover opened 1 year ago

rod-glover commented 1 year ago

Method call in scip/api/__init__.py implements a hand-coded dispatcher. But dispatching is what Flask was invented for: it dispatches an API request to the appropriate method with the @app.route decorator applied to that method. Most of this was copied from PCEX. But that code is 8+ years old, and I don't think it is a good guide to how we should do things. Flask has come a long way since then.

Instead of the call method, I think we can:

Other thoughts:

Notes on Flask:

Alternative: The package Connexion wraps all this up very nicely for you, if you have any interest in adopting it. Several PCIC projects use it. It trades off a significant learning curve for simpler Python code and self-documentation.

corviday commented 1 year ago

thank you for your thoughts!