예제 #1
0
파일: index.py 프로젝트: Ajnasz/pippo
def subscribe():
    response.content_type  = 'text/event-stream'
    response.cache_control = 'no-cache'

    photo = Photo()
    photo.subscribe()

    connected = True

    # Keep connection alive no more then... (s)
    while connected:
        message = photo.pubsub.get_message()

        try:
            if message:
                yield 'data: %s\n\n' % json.dumps(message)
            else:
                yield 'data: %s\n\n' % json.dumps({'keepalive': True})
        except:
             print "disconnected"
	     connected = False

        sleep(1)

    photo.unsubscribe()
예제 #2
0
파일: index.py 프로젝트: Ajnasz/pippo
def take_photo():
    photo = Photo()
    photo.take_photo()

    return {
            'ok': True
    }
예제 #3
0
파일: index.py 프로젝트: Ajnasz/pippo
def subscribe():
    response.content_type = 'text/event-stream'
    response.cache_control = 'no-cache'

    photo = Photo()
    photo.subscribe()

    connected = True

    # Keep connection alive no more then... (s)
    while connected:
        message = photo.pubsub.get_message()

        try:
            if message:
                yield 'data: %s\n\n' % json.dumps(message)
            else:
                yield 'data: %s\n\n' % json.dumps({'keepalive': True})
        except:
            print "disconnected"
            connected = False

        sleep(1)

    photo.unsubscribe()
예제 #4
0
파일: index.py 프로젝트: Ajnasz/pippo
def take_photo():
    photo = Photo()
    photo.take_photo()

    return {'ok': True}