I'm playing with Bottle & Gevent to have an HTTP + WebSockets server. If I were to implement this in Node I'd use Nodemon or similar to restart the server on changes to the code while developing. If I was using just Bottle and the run
method I believe I could use run(reloader=True)
—however I am running the app using WSGIServer
. Given this, how can I have the autoreload functionality I'm after?
http_server = WSGIServer(('127.0.0.1', 8080), app, handler_class=WebSocketHandler)
You don't need an external module. If you set the debug=True, it will reload after every code change. Depending on how you've set up your app, you can do so for instance with app factory:
def create_app(config, debug=True):
....
or from command line:
app.run(debug=True)
or
$ export FLASK_DEBUG=1
$ flask run
After searching on pypi I think that server-reloader will do what you ask.
in your app.py or python file add following lines
app = Flask(__name__)
app.config['DEBUG'] = True
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