📜  使用请求关闭烧瓶服务器 - Python 代码示例

📅  最后修改于: 2022-03-11 14:45:45.812000             🧑  作者: Mango

代码示例1
from flask import request

def shutdown_server():
    func = request.environ.get('werkzeug.server.shutdown')
    if func is None:
        raise RuntimeError('Not running with the Werkzeug Server')
    func()

@app.route('/shutdown', methods=['POST'])
def shutdown():
    shutdown_server()
    return 'Server shutting down...'