def shutdown_server(environ):
    if not 'werkzeug.server.shutdown' in environ:
        raise RuntimeError('Not running the development server')
environ['werkzeug.server.shutdown']()
Start a flask application in separate thread