V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
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
yakczh
V2EX  ›  Python

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

  •  
  •   yakczh · 2013-09-05 15:13:24 +08:00 · 4346 次点击
    这是一个创建于 3892 天前的主题,其中的信息可能已经有所发展或是发生改变。
    14 条回复    1970-01-01 08:00:00 +08:00
    dxjdhm
        1
    dxjdhm  
       2013-09-05 15:16:22 +08:00
    一般的框架,可以打开debug选项吧;打开后就能实现你说的功能!
    est
        2
    est  
       2013-09-05 15:36:31 +08:00   ❤️ 1
    http://blog.est.im/post/34342180038

    一般的WSGI app都可以通过这个办法支持。
    aurorawu
        3
    aurorawu  
       2013-09-05 15:39:16 +08:00
    debug=True
    pengphy
        4
    pengphy  
       2013-09-05 17:35:44 +08:00
    。。。生产环境这么搞 会死的吧
    dexbol
        5
    dexbol  
       2013-09-05 18:05:14 +08:00
    svn hook 如果修改的是 .py 就重启
    dreampuf
        6
    dreampuf  
       2013-09-05 18:29:11 +08:00
    ritksm
        7
    ritksm  
       2013-09-05 18:36:12 +08:00
    watchdog
    yakczh
        8
    yakczh  
    OP
       2013-09-05 18:59:36 +08:00
    @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-09-05 20:21:03 +08:00
    @yakczh

    似乎是你Bottle代码问题。

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


    要么用 default_app
    yakczh
        10
    yakczh  
    OP
       2013-09-05 20:47:42 +08:00
    @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-09-05 21:22:51 +08:00 via Android
    bottle 可以 reloader=True
    yakczh
        12
    yakczh  
    OP
       2013-09-06 10:40:16 +08:00
    @hzymyp  这个reloader=True 改了模板文件竟然没变化,必须要改一下主文件才行
    ericls
        13
    ericls  
       2013-09-22 20:00:42 +08:00
    django可以。。
    部署的时候用uwsgi吧 可以自动reload
    julyclyde
        14
    julyclyde  
       2013-09-23 10:41:11 +08:00
    @yakczh 模板文件只是数据文件而已,不参与编译的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   748 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 21:29 · PVG 05:29 · LAX 14:29 · JFK 17:29
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.