def profile(): user=session['user'] playlist_id = db_edit.findInfo('users', user, 'Username')[0][1] print ('playlist_id') print (playlist_id) songs = db_edit.findInfo('songs',playlist_id,'PlaylistID') return render_template('profile.html', songs=songs, playlist_id=playlist_id, user=session['user'], )
def user_profile(): user = request.form['user'] playlist_id = db_edit.findInfo('users', user, 'Username')[0][1] songs = db_edit.findInfo('songs',playlist_id,'PlaylistID') # print ('--user profile--') # print (user) return render_template('user_profile.html', username=user, songs=songs, playlist_id=playlist_id, )
def users(): user = session['user'] users = db_edit.findInfo('users',user,'Username', notEqual = True) print ('our users') print (users) return render_template('users.html', users=users )
def login(): '''logs the user in by checking if their login info matches with registered user''' username = request.form['usr'].strip() password = request.form['pwd'].strip() user_exists = db_edit.findInfo('users', db_edit.checkApos(username), 'username', fetchOne = True) '''find password for username''' if user_exists: # print (user_exists) # print (password) # print (sha256_crypt.verify(password, user_exists[2])) if sha256_crypt.verify(password, user_exists[2]): session['user'] = username return redirect(url_for('home')) else: flash("Wrong password!") return render_template('home.html') else: flash("Wrong username!") return redirect(url_for('home'))
def play(): '''runs the song algorithm''' tags = request.form.get('tags') s_tags = tags tags = tags.split(',') artist = request.form.get('artist') transit_length = request.form.get('transit_length') route_length = request.form.get('route_length') if transit_length: time = int(transit_length) else: time = int(route_length) print ('---PLAY IS CALLED---') print (type(time)) print (time) # playlist = music.get_tracks_tagged(time, tags) # if len(tags) == 0: # # playlist = music.get_tracks_tagged("None", "None", "None", time) # elif len(tags) == 1: # playlist = music.get_tracks_tagged(tags[0], "None", "None", time) # elif len(tags) == 2: # playlist = music.get_tracks_tagged(tags[0], tags[1], "None", time) # else: # playlist = music.get_tracks_tagged(tags[0], tags[1], tags[2], time) if len(tags) == 0: playlist = music.gen_playlist(time, "None", "None", "None") elif len(tags) == 1: playlist = music.gen_playlist(time, tags[0], "None", "None") elif len(tags) == 2: playlist = music.gen_playlist(time, tags[0], tags[1], "None") else: playlist = music.gen_playlist(time, tags[0], tags[1], tags[2]) # if len(tags) == 0: # playlist = music.gen_playlist(time, "None", "None", "None") # elif len(tags) == 1: # playlist = music.gen_playlist(time, tags[0], "None", "None") # elif len(tags) == 2: # playlist = music.gen_playlist(time, tags[0], tags[1], "None") # else: # playlist = music.gen_playlist(time, tags[0], tags[1], tags[2]) length = len(playlist) time = music.get_total_time(playlist) print (playlist) db_edit.insert('playlists', [time]) playlist_id = db_edit.findInfo('playlists', time, 'Songs')[0][0] print ('play here') print (playlist_id) # print('---HERE---') # print (playlists) # print (transit_time) # playlist = music.gen_playlist(time, tags) for song in playlist: songstuff = [playlist_id, song[2], song[1], song[0]] print (songstuff) db_edit.insert('songs', songstuff) return render_template('play.html', tags=s_tags, playlist = playlist, playlist_id = playlist_id, time = time, length = length )