Python Forum
combining flask webserver and another applicaiton
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
combining flask webserver and another applicaiton
#1
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
Reply
#2
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
Reply
#3
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.
Reply
#4
There is not any code in that flask server Wink
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Handle parameters in POST request for python webserver? JBristow1729 1 7,658 Jul-16-2019, 10:59 PM
Last Post: scidam
  When i try to create a webserver through a port throwing error pras120687 2 5,729 Dec-14-2016, 01:06 AM
Last Post: pras120687

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020