如何使用 nodemon 在 Python 文件更改时自动重启 bottle 服务器
假设你有一个 Python 脚本 server.py,你想在每次文件更改时自动重新加载,使用以下 nodemon 脚本:
nodemon_start.sh
nodemon -w . --exec python server.pynodemon_start.sh
nodemon -w . --exec python server.py-w . 告诉 nodemon 监视当前目录(.)中所有文件的更改
我通常建议创建一个脚本 start.sh 来自动运行此命令:
start_nodemon.sh
#!/bin/sh
nodemon -w . --exec python server.pystart.sh
#!/bin/sh
nodemon -w . --exec python server.py然后使用以下命令使其可执行
chmod_start.sh
chmod a+x start.shchmod_start.sh
chmod a+x start.sh现在你可以使用以下命令运行它
run_start.sh
./start.shrun_start.sh
./start.shCheck out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow