Ejemplo n.º 1
0
def get_document(document_id):
    if get_connection() is None:
        try_reconnecting()
    if request.method == 'GET':
        try:
            result = load_document(document_id, current_user.get_id())
            return respond_with(result)
        except Exception, e:
            print e
            reset_connection()
            return 'Error while loading the document.', 500
Ejemplo n.º 2
0
def login():
    if get_connection() is None:
        try_reconnecting()
    req = request.get_json()
    if req and 'username' in req and 'password' in req:
        try:
            user = load_user(req['username'])
            if user and req['password'] == user.token:
                login_user(user, remember=True)
                user.token = None
                return respond_with(user.__dict__)
        except Exception, e:
            reset_connection()
            return str(e) + " Please try again later.", 500