Exemplo n.º 1
0
def home():
    if request.method == 'GET':
            un = ""
            ps = ""
            if request.cookies.get('username'):
    		un = request.cookies.get('username')
    		ps = request.cookies.get('password')
            if g.user:
                songs = []
                for i in g.user["mysongs"]:
                     songs.append(str(i))
        	return render_template('index.html', name=g.user["firstname"], email=g.user["email"], chords=db.returnChords(g.user["username"]), songs=songs)
            elif db.is_puser(un, ps):
                songs = []
                for i in db.get_puser(un,ps)["mysongs"]:
                     songs.append(str(i))
        	return render_template('index.html', name=db.get_puser(un,ps)["firstname"], email=db.get_puser(un,ps)["email"], chords=db.returnChords(un), songs= songs)
            else:
                return render_template('login.html', next=oid.get_next_url(), error=oid.fetch_error())
    if request.method == 'POST':
    	button = request.form['button']
    	if button == 'Sign up':
    		return redirect("/signup")
    	elif button == 'Find':
    		mysongquery= request.form['mysongquery']
                if mysongquery == "":
                    flash("Please enter a song name.")
                    return redirect("/")
    		return redirect("/songs/"+mysongquery)
    	elif button == 'Sign in':
        	username = request.form['user']
        	password = request.form['pass']
        	if db.is_puser(username, password):
        		resp = make_response(redirect("/"))
        		resp.set_cookie('username', username)
        		resp.set_cookie('password', password)
        		return resp
        	else:
        		return redirect("/")
Exemplo n.º 2
0
def songs(song):
	if request.method == 'POST':
        	hiddenChord = request.form["hiddenChord"]
        	hiddenChord = hiddenChord[1:-1].split(',')
        	if g.user:        	 	 
        	 	 db.pushChords(g.user["username"],hiddenChord)
        	 	 db.pushSong(g.user["username"],str(song))
        	 	 return redirect("/")
        	elif request.cookies.get('username'):
        		un = request.cookies.get('username')
        		db.pushChords(un,hiddenChord)
        		db.pushSong(un,str(song))
        		return redirect("/")
        	else:
        		 return redirect("/")

	if request.method == 'GET':
            un = ""
            ps = ""
            
            if request.cookies.get('username'):
    		un = request.cookies.get('username')
    		ps = request.cookies.get('password')
            if g.user:
                chords = []
                songs = []
                for i in g.user["mysongs"]:
                    songs.append(str(i))
                print(songs)
                return render_template('songs.html', song=song, name=g.user["firstname"], email=g.user["email"], chords=db.returnChords(g.user["username"]), songs=songs)
            elif db.is_puser(un, ps):
                chords = []
                songs = []
                for i in db.get_puser(un,ps)["mysongs"]:
                    songs.append(str(i))
        	return render_template('songs.html', song=song, name=db.get_puser(un,ps)["firstname"], email=db.get_puser(un,ps)["email"], chords=db.returnChords(un), songs= songs)
            else:
                return redirect("/")
Exemplo n.º 3
0
def tutorial(page):
    if request.method == 'GET':
        un = ""
        ps = ""
        if request.cookies.get('username'):
            un = request.cookies.get('username')
            ps = request.cookies.get('password')
        if g.user:
            songs = []
            for i in g.user["mysongs"]:
                 songs.append(str(i))
            
            return render_template('tutorial.html', page=int(page), name=g.user["firstname"], email=g.user["email"], chords=db.returnChords(g.user["username"]), songs=songs)
        elif db.is_puser(un, ps):
            songs = []
            for i in db.get_puser(un,ps)["mysongs"]:
                 songs.append(str(i))
            
            return render_template('tutorial.html', page=int(page), name=db.get_puser(un,ps)["firstname"], email=db.get_puser(un,ps)["email"], chords=db.returnChords(un), songs= songs)
        else:
            return redirect("/")