2012-04-01 34 views
0

我有燒瓶運行wsgiserver的ontop。它是從以下開始..如何關閉帶燒瓶的wsgiserver ontop

d = wsgiserver.WSGIPathInfoDispatcher({'/': app}) 
server = wsgiserver.CherryPyWSGIServer(('0.0.0.0', 7000), d) 

if __name__ == '__main__': 

    try: 
     server.start() 

    except KeyboardInterrupt: 
     server.stop() 

我該如何阻止它?所以..

@app.route('/stop') 
@requires_auth 
def stop(): 
    CODE TO STOP HERE 

我已經搜索谷歌高和低,沒有發現我的工作。請有人協助。由於

回答

0

你應該能夠做這樣的事情:

def run(): 
    d = wsgiserver.WSGIPathInfoDispatcher({'/': app}) 
    server = wsgiserver.CherryPyWSGIServer(('0.0.0.0', 7000), d) 

    @app.route('/stop') 
    @requires_auth 
    def stop(): 
     server.stop() 

    try: 
     server.start() 

    except KeyboardInterrupt: 
     server.stop() 

if __name__ == '__main__': 
    run()