3 from wsgiref import simple_server
4 from wsgiref.handlers import SimpleHandler
5 from wsgiref.simple_server import WSGIServer
7 from bottle import route, run
9 simple_server.ServerHandler = SimpleHandler # Stop logging to stdout
12 class QuitWSGIServer(WSGIServer):
15 def serve_forever(self):
16 while not self._quit_flag:
22 QuitWSGIServer._quit_flag = True
23 return "The program has finished. Have a nice day!"
26 def run_server(host='localhost', port=0):
27 # Start here so that bottle can find templates
28 os.chdir(os.path.dirname(__file__))
29 sys.path.insert(0, os.getcwd()) # To import Cheetah templates
30 run(host=host, port=port, server_class=QuitWSGIServer, debug=True)