I want to run this piece of code in the background during start up.
from front import flask_server
from win10toast import ToastNotifier
toast = ToastNotifier()
toast.show_toast("input server running", "The server is running", duration=5)
flask_server.get_app().run(host="0.0.0.0", port=80)
I have made a shortcut to it and put it inside shell:start up in Windows. This is a .pyw file so it doesn't launch a command line window. Problem is that the flask server doesn't run unless I make the python file a .py which launches a command line window, which is not what I want. The flask_server.get_app() function returns the flask app, defined in the "flask_server.py" program as app = Flask(__name__)
This is the code to return the app to the runner program
def get_app():
return app
The server must run in the background and receive requests, but it looks like after the notification in the runner program has popped up, windows kills the flask process and doesn't accept requests.
I have tried to make it a service using sc.exe but it didn't start the script at all