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
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
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())
        g_cntrWiFi = InternetCheck(g_cntrWiFi)
        updateLog = UpdateOutputs()
        g_logFileName = LogData(updateLog, g_logFileName)
    GPIO.cleanup() # cleanup all GPIO 
Flask web server code snippet:
app = Flask(__name__)

if __name__ == "__main__":, debut=True)
As soon as is executed, nothing else gets executed.
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.

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

Forum Jump:

User Panel Messages

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