def account(usr): if not 'username' in session: return redirect('/') user_list = reader.getCsvDict("./util/credentials.txt") if not usr in user_list.keys(): return render_template( "error.html", error="The username you have provided does not exist.", globe=globe) img = reader.getCsvDict('util/pfpimg.txt') userinfo = user_list[usr] gender = userinfo[1] Countryin = userinfo[2] Target = userinfo[3] url = '/account/' + session['username'] + '/settings' if session['username'] == usr: own = True else: own = False if usr in img: img = img[usr][0] else: img = 'http://s3-static-ak.buzzfed.com/static/2014-07/14/12/campaign_images/webdr09/meet-lunita-the-cutest-baby-sloth-on-planet-earth-2-9684-1405357019-4_big.jpg' return render_template("account.html", user=usr, user_list=user_list, globe=globe, img=img, gender=gender, Country=Countryin, target=Target, own=own, dir=url)
def home(): if not 'username' in session: return redirect('/') user_list = reader.getCsvDict('./util/credentials.txt') current = user_list[session['username']][3] del user_list[session['username']] g = 0 rect = False rec = [] for i in user_list.keys(): if user_list[i] == current: rec.append(user_list.items()[g][0]) rect = True g += 1 if rec != []: rec = choice(rec) usr = session['username'] url = '/account/' + usr + '/sendmessage' if not rect: return render_template('home.html', user=session['username'], prof='/account/' + session['username'], recomended=rect, dir=url) return render_template('home.html', user=session['username'], prof='/account/' + session['username'], rec='/account/' + rec, recomended=rect, dir=url)
def sendmessage(usr): reader.write_file('./util/' + usr + 'message.txt', '', 'a') url = '/account/' + usr + '/sendmessage' if not 'username' in session: return redirect('/') user_list = reader.getCsvDict('./util/credentials.txt').keys() messages = reader.read_file('./util/' + usr + 'message.txt') messages = messages.split('\n') messages.pop(-1) if messages == ['']: out = False else: out = True if request.method == 'GET': return render_template('messages.html', dir=url, messages=messages, out=out) elif request.method == 'POST': if not request.form['recipient'] in user_list: return render_template('messages.html', dir=url, messages=messages, out=out) mess.sendMessage(session['username'], request.form['recipient'], request.form['message']) return redirect(url)
def account(usr): if not 'username' in session: return redirect('/') user_list = reader.getCsvDict("./util/credentials.txt") if not usr in user_list.keys(): return render_template("error.html",error = "The username you have provided does not exist.",globe=globe) img=reader.getCsvDict('util/pfpimg.txt') userinfo=user_list[usr] gender=userinfo[1] Countryin=userinfo[2] Target=userinfo[3] url='/account/'+session['username']+'/settings' if session['username']==usr: own=True else: own=False if usr in img: img=img[usr][0] else: img='http://s3-static-ak.buzzfed.com/static/2014-07/14/12/campaign_images/webdr09/meet-lunita-the-cutest-baby-sloth-on-planet-earth-2-9684-1405357019-4_big.jpg' return render_template("account.html",user = usr,user_list = user_list,globe=globe, img=img,gender=gender,Country=Countryin,target=Target,own=own,dir=url)
def sendmessage(usr): reader.write_file('./util/'+usr+'message.txt','','a') url='/account/'+usr+'/sendmessage' if not 'username' in session: return redirect('/') user_list=reader.getCsvDict('./util/credentials.txt').keys() messages=reader.read_file('./util/'+usr+'message.txt') messages=messages.split('\n') messages.pop(-1) if messages==['']: out=False else: out=True if request.method=='GET': return render_template('messages.html',dir=url,messages=messages,out=out) elif request.method=='POST': if not request.form['recipient'] in user_list: return render_template('messages.html',dir=url,messages=messages,out=out) mess.sendMessage(session['username'],request.form['recipient'],request.form['message']) return redirect(url)
def home(): if not 'username' in session: return redirect('/') user_list=reader.getCsvDict('./util/credentials.txt') current=user_list[session['username']][3] del user_list[session['username']] g=0 rect=False rec=[] for i in user_list.keys(): if user_list[i]==current: rec.append(user_list.items()[g][0]) rect=True g+=1 if rec!=[]: rec=choice(rec) usr=session['username'] url='/account/'+usr+'/sendmessage' if not rect: return render_template('home.html',user=session['username'],prof='/account/'+session['username'],recomended=rect,dir=url) return render_template('home.html',user=session['username'],prof='/account/'+session['username'],rec='/account/'+rec,recomended=rect,dir=url)