I'm really enjoying Bottle so far, but the fact that I have to CTRL+C out of the server and restart it every time I make a code change is a big hit on my productivity. I've thought about using Watchdog to keep track of files changing then restarting the server, but how can I do that when the bottle.run
function is blocking.
Running the server from an external script that watches for file changes seems like a lot of work to set up. I'd think this was a universal issue for Bottle, CherryPy and etcetera developers.
Thanks for your solutions to the issue!
When starting a bottle webserver without a thread or a subprocess, there's no problem. To exit the bottle app -> CTRL + c .
Bottle framework learning checklistDownload Bottle or install via pip with pip install bottle on your local development machine. Work through the official Bottle tutorial. Start coding your Bottle app based on what you learned in the official tutorial plus reading open source example applications found above.
Check out from the tutorial a section entitled "Auto Reloading"
During development, you have to restart the server a lot to test your recent changes. The auto reloader can do this for you. Every time you edit a module file, the reloader restarts the server process and loads the newest version of your code.
This gives the following example:
from bottle import run run(reloader=True)
With
run(reloader=True)
there are situations where it does not reload like when the import is inside a def. To force a reload I used
subprocess.call(['touch', 'mainpgm.py'])
and it reloads fine in linux.
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