示例#1
0
def logout():
    try:
        token = request.headers['Authorization']
        print(token)
        if DBSessions.select().where(DBSessions.token == token).count() == 1:
            DBSessions.delete().where(DBSessions.token == token).execute()
            return "Ok"
        return "Error"
    except:
        return "Error"
示例#2
0
def login(email, password, ip):
    answer = ''
    result = DBUser.select(DBUser.id).where((DBUser.email == email) & (DBUser.password == hashlib.sha256(password.encode('utf-8')).hexdigest()))
    if result and result.count() == 1:
        for item in result:
            answer = uuid4()
            DBSessions.create(id = item.id, token = answer)
    else:
        print("No info")
    print("--",answer)
    return {'token':str(answer)}
示例#3
0
def get_place_id_server(id):
    try:
        token = request.headers['Authorization']
        if DBSessions.select().where(DBSessions.token == token).count() == 1:
            return get_place(id)
        return "Error"
    except:
        return "Error"
示例#4
0
def add_place_server():
    try:
        token = request.headers['Authorization']
        print(DBSessions.select().where(DBSessions.token == token).count())
        if DBSessions.select().where(DBSessions.token == token).count() == 1:
            return add_place(
                request.json["name"],
                request.json["description"],
                request.json["lat"],
                request.json["lng"],
                request.json.get('image'),
                request.json["type"]
            )
        else:
            return "Error"
    except:
        return "Error"
示例#5
0
def get_route_places_server(id):
    response.headers['Content-type'] = 'application/json'
    try:
        token = request.headers['Authorization']
        if DBSessions.select().where(DBSessions.token == token).count() == 1:
            return get_route_places(id)
        return "Error"
    except:
        return "Error"
示例#6
0
def remove_route_server(id):
    try:
        token = request.headers['Authorization']
        if DBSessions.select().where(DBSessions.token == token).count() == 1:
            # request.forms.get("title")
            return remove_route(
                id
            )
        return "Error"
    except:
        return "Error"
示例#7
0
def add_route_server():
    try:
        token = request.headers['Authorization']
        if DBSessions.select().where(DBSessions.token == token).count() == 1:
            return add_route(
                request.json["name"],
                request.json["description"],
                request.json["total_places"],
                request.json["places"],
                request.json.get('image')
            )
        else:
            return "Error"
    except:
        return "Error"