Flask as middleware for IOT solutions
A few months ago, our R&D team was on the lookout for a flexible tool-kit that can act as a middleware in our IoT gateway development practices. The main requirement was that it should push the data to a REST API framework and the users should have the flexibility to use it anyway they want.
We had thought about the ever so popular Django framework initially but decided to zero in on Flask, just because it was light-weight and delivered a better performance. Compared to other frameworks, Flask’s documentation was much intuitive
Flask is an extremely popular micro web framework that works on minimal infrastructure and does not need any specific libraries or tools. Written in Python language, Flask is compact and robust to setup and hardly you will find an unused functionality therein. In our solution architecture, Flask API acts as middleware and gives us the liberty to connect with the end client that supports REST protocol.
Our IoT powered industrial monitoring solutions handle a large amount of real-time data transfer. So, it was important to have a middleware entity that uses minimal infrastructure and give us maximum performance. The data comes through the sensors that are handled by MQTT infrastructure and stored in InfluxDB time-series database.
Flask gateway development API
The API would read the data from the database and the same can be used by third-party platforms like OpenHab 2 or KepWare. We have worked extensively in OpenHab 2 platform and found it to be an extremely useful tool for data handling & visualization.
Another feature of Flask we liked very much is its ability to function both in cloud and on-premise setup. In an on-premise model, Flask can be deployed in a local WSGI server. It also has good authentication policies and supports open authentication frameworks. When the API is configured, we can access it directly from the browser and can be used to make API requests such as GET, PUT, POST & DELETE.
We can safely say that Flask delivered a consistent and improved performance as a middleware for our IoT gateway.