mercredi 20 janvier 2021

How to add a Flask API to a backend project?

I've developed a backend project using Python. It collects data from different sources, process the data and then perform actions with it (for example, store relevant info in a database). To execute it, I just do "python main.py" and it starts the daemon process.

Now I want to add a Flask API in order to interact with this collector: start/stop the collection, see the state of each component, add/remove components... What is the best approach to do it? I can't just add Flask app object and routes to the same project, because when I deploy the Api using gunicorn with several workers it runs several instances of the collector. Should I code the API in a separate project and the communicate both the API and the collector through some tool?

Aucun commentaire:

Enregistrer un commentaire