Answer the question
In order to leave comments, you need to log in
How to reload Flask with a site request?
Good afternoon.
On Flask-plugins, I saw an example code of how you can restart the server by clicking on a button on the site. An example for Linux, but I will need it to work on Windows in addition to Linux.
According to the answers on Stackoverflow, the following is obtained:
@app.route('/restart')
def restart_flask():
args = [sys.executable] + sys.argv[:]
os.execv(sys.executable, args)
return("")
Answer the question
In order to leave comments, you need to log in
You configure uwsgi to reboot via touch (touch-reload).
You call touch in the view.
PROFIT
I found that LiveReload has some issues when running on Windows. In particular, Flask does not always reload. Sometimes Python.exe crashes.
I have decided that this feature will only be used in the web version that will run on Linux. And under Windows it will no longer be flask, but something else. Accordingly, my question is no longer relevant.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question