Run waitress server with Flask and Pywebview

If I pass the flask instance to pywebview is uses the bottle server.

app = Flask(__name__)

if __name__ == '__main__':
    webview.create_window('Flask example', app)
    webview.start(debug=True)

I am trying to figure out how to use the waitress server without creating an additional thread.
I can do it like this with another thread:

def waitress():
    serve(app, host="127.0.0.1", port=5000)

if __name__ == '__main__':
    waitress_thread = threading.Thread(target=waitress)
    waitress_thread.start()

    webview.create_window('Flask example', 'http://127.0.0.1:5000')
    webview.start(debug=True)

Wondered if it’s possible to pass this serve(app, host="127.0.0.1", port=5000) directly to webview.create_window()

Any help would be appreciated. I have asked at the git repo, just double asking here in case someone knows. Alternatively it doesn’t have to be a waitress server an alternative windows production ready one will do.

Thanks

Leave a Comment