如何在顶部关闭带烧瓶的wsgiserver

时间:2012-04-01 16:03:50

标签: python flask

我在wsgiserver上运行烧瓶。它从以下开始..

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

我搜索了谷歌的高低,我发现没有任何效果。请有人帮忙。感谢

1 个答案:

答案 0 :(得分: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()
相关问题