繁体   English   中英

自动重新加载在Bottle框架中不起作用

[英]Auto reloading is not working in Bottle framework

我目前正在开始使用Bottle框架(执行Hello World示例,之后必须构建RESTful API)。 问题是重新加载器不起作用。 当我在代码中进行更改并重新加载页面时,更改应该显示没有任何反应。 它适用于我朋友的电脑,所以我有点困惑。

使用python 2.7。

from bottle import route, run

@route('/hello')
def hello():
    return "Hello World!"

run(host='localhost', port=8080, debug=True, reloader =True)

编辑:我注意到的是,当我在服务器仍在监听时保存脚本中的更改时,我得到了这个:

----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 60472)
Traceback (most recent call last):
  File "C:\Python27\lib\SocketServer.py", line 290, in _handle_request_noblock
    self.process_request(request, client_address)
  File "C:\Python27\lib\SocketServer.py", line 318, in process_request
    self.finish_request(request, client_address)
  File "C:\Python27\lib\SocketServer.py", line 331, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "C:\Python27\lib\SocketServer.py", line 652, in __init__
    self.handle()
  File "C:\Python27\lib\wsgiref\simple_server.py", line 116, in handle
    self.raw_requestline = self.rfile.readline(65537)
  File "C:\Python27\lib\socket.py", line 480, in readline
    data = self._sock.recv(self._rbufsize)
KeyboardInterrupt
----------------------------------------

如果您使用Windows操作系统,有一个有趣的线索

请记住,在windows中,如果name ==“ main ”,则必须处于以下状态:由于多处理模块的工作方式。

所以看起来应该是这样的

from bottle import route, run

@route('/hello')
def hello():
    return "Hello World!"

if __name__ == "__main__":
    run(host='localhost', port=8080, debug=True, reloader=True)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM