Exemplo n.º 1
0
def connect():
    """Connects to the stats client, using the endpoint that's passed in the
    POST body.
    """
    def _ask_connection():
        return render_template('connect.html')

    if request.method == 'GET':
        return _ask_connection()

    elif request.method == 'POST':
        # if we got an endpoint in the POST body, store it.
        if request.forms.endpoint is None:
            return _ask_connection()

        endpoint = request.forms.endpoint
        client = connect_to_circus(endpoint)
        if not client.connected:
            set_message('Impossible to connect')

        redirect('/')
Exemplo n.º 2
0
def disconnect():
    if disconnect_from_circus():
        set_message('You are now disconnected')
    redirect('/')