コード例 #1
0
ファイル: app.py プロジェクト: pranjalmittal/FollowMe
def profile_page(userid):
    # print session['username']
    if 'username' not in session:
        return abort(403)
    else:
        res = fetch_profile_data(userid)
        foo = db_init()
        cursor = foo.cursor()
        q = "select user_id from users where username = '******'" % session['username']
        # query = "select fid from friends where uid = %s" % userid
        

        cursor.execute(q)
        result = cursor.fetchall()
        query = "select fid from friends where uid = %s" % userid
        cursor.execute(query)
        result += cursor.fetchall()
        db_close(foo)
        
        
        # if not all(row):
        #     row = row
        # else:
        #     row.add(userid)
        result = [int(i[0]) for i in result]
        return render_template("home.html", res = res, result = result)
コード例 #2
0
def register_user_method(d):
    foo = db_init()
    cursor = foo.cursor()
    query = "insert into users (firstName, lastName, username, password, desp) VALUES ('%s','%s','%s','%s','%s')" % (d['firstName'], d['lastName'], d['username'], d['password'] , d['description'])
    cursor.execute(query)
    foo.commit()
    db_close(foo)
    
コード例 #3
0
ファイル: profile.py プロジェクト: pranjalmittal/FollowMe
def fetch_profile_data(d):
    foo = db_init()
    cursor = foo.cursor()
    query = "select * from users where user_id = %s" % d
    cursor.execute(query)
    
    row = cursor.fetchall()
    db_close(foo)
    return row
    
コード例 #4
0
ファイル: app.py プロジェクト: pranjalmittal/FollowMe
def list_all():
    if 'username' not in session:
        return abort(403)
    else:
        foo = db_init()
        cursor = foo.cursor()
        query = "select * from users order by firstName"
        cursor.execute(query)
        row = cursor.fetchall()
        db_close(foo)
        return render_template("allusers.html", res = row)
コード例 #5
0
ファイル: fetch_data.py プロジェクト: pranjalmittal/FollowMe
def fetch_data_method(d):
    foo = db_init()
    cursor = foo.cursor()
    query = "select * from users where username='******' and password='******'" % (d['username'], d['password'])
    cursor.execute(query)
    # foobar.close()
    
    # for row in foobar.fetchall():
    #     return row
    
    row = cursor.fetchall()
    return row
コード例 #6
0
ファイル: add_friend.py プロジェクト: pranjalmittal/FollowMe
def add_friend_method(a,b):
    foo = db_init()
    cursor = foo.cursor()
    q = "select user_id from users where username = '******'" % a
    cursor.execute(q)
    result = cursor.fetchall()
    # print result[0][0]
    query = "insert into friends values(%s, %s)" % (result[0][0], b)
    cursor.execute(query)
    foo.commit()

    # row = cursor.fetchall()
    db_close(foo)
    # return row
コード例 #7
0
ファイル: login_user.py プロジェクト: pranjalmittal/FollowMe
def login_user_method(d):
    foo = db_init()
    cursor = foo.cursor()
    query = "select * from users where username = '******' and password = '******'" % (d['username'], d['password'])
    cursor.execute(query)
    
    # for row in foobar.fetchall():
    #     print row[1]
    count = 0
    for row in cursor.fetchall():
        count = count + 1
        cursor.close()
        return row
        
    cursor.close()
    return count
コード例 #8
0
ファイル: app.py プロジェクト: pranjalmittal/FollowMe
def login_success():
    if 'username' not in session:
        return abort(403)
    res =  fetch_data_method(session)
    foo = db_init()
    cursor = foo.cursor()
    query = "select user_id from users where username = '******'" % session['username']
    cursor.execute(query)
    row = cursor.fetchall()
    print row
    qu = "select fid from friends where uid = %s order by fid" % row[0][0]
    cursor.execute(qu)
    row += cursor.fetchall()
    print row
    db_close(foo)
    row = [int(i[0]) for i in row]
    return render_template("home.html", res=res, result = row)