简体   繁体   中英

Auto reloading is not working in Bottle framework

I am currently getting started with Bottle framework (doing the Hello World example and afterwards have to build a RESTful API). The problem is the fact that reloader doesn't work. When I make a change in the code and reload the page where the change should show nothing happens. It works on my friends' computers so I'm am a bit confused.

Using python 2.7.

from bottle import route, run

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

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

EDIT:Also what i noticed is that when i save the change in the script while the server is still listening i get this:

----------------------------------------
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
----------------------------------------

There is an interesting clue if you use Windows OS:

Keep in mind that in windows this must be under if name == " main ": due to the way the multiprocessing module works.

So it should look like this

from bottle import route, run

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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