tckh
tckh

Reputation: 1

Python control kivy app with web interface

I have created a kivy gui for controlling the GPIO Pins of the Raspberry Pi. In the kivy app i import my python file, where i defined my functions for setting the outputs and make calculations. Now i want to control these functions with a web interface, and parallel with my local GUI on a Touchscreen.

I have seen that there exists Frameworks like Flask or Django, my Question is how do i get the connection between my running Framework(like Flask) and the existing functions which are already local used, is there a recommended way?

Upvotes: 0

Views: 1217

Answers (1)

d21d3q
d21d3q

Reputation: 385

I am standing in front of similar problem, so here are my ideas:

Theoretically it should be possible to combine flask and kivy in one app in separate threads, but I won't event try to make it because they are quite big frameworks and debugging it would be overwhelming (or making it work with nginx).

Option 1

Use two separate applications - kivy and flask. Kivy works as master it does all the logic, controls GPIOs ect. Every time you load (GET) page or POST changes, flask is calling kivy via grpc to get current state, calculations or to set GPIO.

Option 2

Use three applications. One of them is controlling GPIOs, doing calculations and having all logic. Two other applications are flask and kivy which talk with first one also via grpc.

Option 3

Any of previous with database.

In my case I will use second option with database, but mostly because I need persistence of data (past events, configuration) between resets so that I will use some database (mongo) as a medium of communication. Maybe I will also introduce some grpc - main app will have updateConfig function so that it won't have to check all the time DB for changes

Upvotes: 1

Related Questions