yakczh
V2EX  ›  Python

python的web框架有没有可以修改代码让服务器自动重启的包?

By yakczh at 2013 年 9 月 5 日 · 5580 次点击
14 条回复  •  1970-01-01 08:00:00 +08:00
dxjdhm
   1
dxjdhm  
   2013 年 9 月 5 日
一般的框架,可以打开debug选项吧;打开后就能实现你说的功能!
est
   2
est  
   2013 年 9 月 5 日   ❤️ 1
http://blog.est.im/post/34342180038

一般的WSGI app都可以通过这个办法支持。
aurorawu
   3
aurorawu  
   2013 年 9 月 5 日
debug=True
pengphy
   4
pengphy  
   2013 年 9 月 5 日
。。。生产环境这么搞 会死的吧
dexbol
   5
dexbol  
   2013 年 9 月 5 日
svn hook 如果修改的是 .py 就重启
ritksm
   7
ritksm  
   2013 年 9 月 5 日
watchdog
yakczh
   8
yakczh  
OP
   2013 年 9 月 5 日
@est

from bottle import run,route, Bottle

app = Bottle()

@route('/hello')
def hello():
return "Hello World!"
@route('/')
def home():
article = {'name': 'A Royal Baby', 'body':'A slow news week'}
return article

def dev_server():
run(app, host='0.0.0.0', port=8080, debug=True)

if '__main__' == __name__:
from django.utils import autoreload
autoreload.main(dev_server)


这样写,访问 http://localhost/hello 提示404
est
   9
est  
   2013 年 9 月 5 日
@yakczh

似乎是你Bottle代码问题。

@route()
改成
@app.route()


要么用 default_app
yakczh
   10
yakczh  
OP
   2013 年 9 月 5 日
@est 这是http://bottlepy.org/docs/dev/ 上复制的代码 

改成@app.route可以,但是每次请求控制台都报异常

return super(FixedHandler, self).log_request(*args, **kw)
TypeError: super() argument 1 must be type, not classobj
hzymyp
   11
hzymyp  
   2013 年 9 月 5 日 via Android
bottle 可以 reloader=True
yakczh
   12
yakczh  
OP
   2013 年 9 月 6 日
@hzymyp  这个reloader=True 改了模板文件竟然没变化,必须要改一下主文件才行
ericls
   13
ericls  
   2013 年 9 月 22 日
django可以。。
部署的时候用uwsgi吧 可以自动reload
julyclyde
   14
julyclyde  
   2013 年 9 月 23 日
@yakczh 模板文件只是数据文件而已,不参与编译的
推荐学习书目
› Learn Python the Hard Way
Python Sites
› PyPI - Python Package Index
› http://diveintopython.org/toc/index.html
› Pocoo
值得关注的项目
› PyPy
› Celery
› Jinja2
› Read the Docs
› gevent
› pyenv
› virtualenv
› Stackless Python
› Beautiful Soup
› 结巴中文分词
› Green Unicorn
› Sentry
› Shovel
› Pyflakes
› pytest
Python 编程
› pep8 Checker
Styles
› PEP 8
› Google Python Style Guide
› Code Style from The Hitchhiker's Guide
© 2026 V2EX · 36ms · 3.9.8.5