I have an application that runs a dehumidifier, through a loop in main(). I have a flask web server to provide a web interface for the dehumidifier. Currently these are separate.
How do I add my main() code into the web server application?
Alternatively how do I make the applications talk to each other?
Where would I start?
Any help would be appreciated.
Thank you
Maciej
hard to say without seeing any code or structure.. but i belive you need to make it as a threaded app with some background tasks
Main application (Raspberry Pi)
def main():
# Initialize log file to empty on start up
g_logFileName = EMPTY
g_cntrWiFi = int(time.perf_counter())
while(1):
g_cntrWiFi = InternetCheck(g_cntrWiFi)
readSwitches()
SenseCheck()
UpdateDisplay()
DeHumidifyLogic()
updateLog = UpdateOutputs()
g_logFileName = LogData(updateLog, g_logFileName)
time.sleep(0.1)
GPIO.cleanup() # cleanup all GPIO
main()
Flask web server code snippet:
app = Flask(__name__)
if __name__ == "__main__":
app.run(port=5000, debut=True)
As soon as app.run is executed, nothing else gets executed.
There is not any code in that flask server
Look at this
Thread so there i use
APScheduler and
send value to client trough
jinja.
So
parse_func()
could be your main function if it return anything,
or you could read the saved logged file in interval.
In this
Thread do interval reading from client side with
AJAX.