I am using waitress to serve the web application content like.
waitress-serve --port=8000 myapp:application
While developing, as I change code, I continuously had to restart the waitress-serve to see my changes. Is there a standard way I can automate this?
I know this is an old question but I had a similar issue trying to enable hot reload functionality for my REST API using Falcon framework.
Waitress does not monitor file changes but you could use hupper
on top of it. Pretty simple:
$ pip install hupper
$ hupper -m waitress --port=8000 myapp:application
It works on Windows too.
Based on the comment by @Dirk, I found the archive.org link to the snippet mentioned. I was able to get Waitress reloading by using Werkseug directly. Using Werkzeug's decorator run_with_reloader
causes the app to restart whenever a Python file changes. (Werkzeug is used within Flask so it should be available).
Additionally, the app.debug = True
line causes Flask to reload template files when they change. So you may want both considering your particular situation.
import werkzeug.serving
@werkzeug.serving.run_with_reloader
def run_server():
app.debug = True
waitress.serve(app, listen='127.0.0.1:4432')
if __name__ == '__main__':
run_server()
Once I had my server set up this way, it auto-reloaded the server whenever any file changed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With