JDoe
JDoe

Reputation: 63

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

Upvotes: 3

Views: 1352

Answers (1)

Piotr Dawidiuk
Piotr Dawidiuk

Reputation: 3092

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)

Upvotes: 4

Related Questions