def index(): if current_user.is_authenticated: return redirect(url_for('stream', username=current_user.username)) form = IndexForm() form.register = RegisterForm() if form.login.is_submitted() and form.login.submit.data: user = User.query.filter_by(username = form.login.username.data).first() if user == None or form.login.username.data == '': flash('Invalid username or password!') elif user.check_password(form.login.password.data): login_user(user, remember=form.login.remember_me.data) return redirect(url_for('stream', username=form.login.username.data)) else: flash('Invalid username or password!') elif form.register.is_submitted() and form.register.submit.data and form.register.validate(): user = User(username=form.register.username.data, first_name=form.register.first_name.data, last_name=form.register.last_name.data) user.set_password(form.register.password.data) db.session.add(user) db.session.commit() return redirect(url_for('index')) return render_template('index.html', title='Welcome', form=form)
def user(username): user = User.query.filter_by(username=username).first_or_404() indexForm = IndexForm() checkForm = CheckForm() newestday = Date.query.order_by( Date.day.desc()).first() # THis way our newest day is first in table date = newestday.day indexForm.date.choices = [ (str(date.day), str(date.day)) for date in Date.query.order_by(Date.day.desc()).all() ] usershares = StockShares.query.filter_by(date=date).join( UserShares, UserShares.user_company == StockShares.stockName).filter_by( user_id=current_user.id).all() if indexForm.submitDate.data and indexForm.validate_on_submit(): date = indexForm.date.data usershares = StockShares.query.filter_by(date=date).join( UserShares, UserShares.user_company == StockShares.stockName).filter_by( user_id=current_user.id).all() return render_template('myshares.html', user=user, usershares=usershares, indexForm=indexForm, checkForm=checkForm)
def index(request): if request.method =='POST': form= IndexForm(request.POST) if form.is_valid(): aux = request.POST.get("Tema") latest_question_list = Pregunta.objects.filter(question_tema=aux) template = loader.get_template('polls/index.html') context = { 'form': form, 'title':'Lista de preguntas de la encuesta', 'latest_question_list': latest_question_list, } return render(request, 'polls/index.html', context) #form.save() else: latest_question_list = Pregunta.objects.order_by('-pub_date') template = loader.get_template('polls/index.html') form= IndexForm(request.GET) context = { 'form': form, 'title':'Lista de preguntas de la encuesta', 'latest_question_list': latest_question_list, } return render(request, 'polls/index.html', context)
def index(): form = IndexForm() if form.validate_on_submit(): return redirect(url_for('game')) elif request.method == 'GET': form.language = 0 return render_template('index.html', form=form)
def index(): form = IndexForm() if form.validate_on_submit( ): #when form is submitted then this block of code will be run i.e. on POST return redirect(url_for('search', usertype=form.usertype.data)) return render_template( 'index1.html', title="Home", form=form) #Pass the form object on top if it is a GET request
def index(): form = IndexForm() if form.login.validate_on_submit() and form.login.submit.data: preparedQuery = 'SELECT * FROM Users WHERE username=?;' user = safe_query(preparedQuery, (form.login.username.data.lower(),), one=True) if user is None: flash('Sorry, invalid credentials!') elif check_password_hash(user['password'], form.login.password.data): app_user = load_user(int(user['id'])) login_user(app_user) return redirect(url_for('stream')) else: flash('Sorry, invalid credentials!') elif form.register.validate_on_submit() and form.register.submit.data: preparedQuery = 'SELECT * FROM Users WHERE username=?;' existing_user = safe_query(preparedQuery, (form.register.username.data.lower(),), one=True) if existing_user is not None: flash('Sorry, invalid username!') elif form.register.password.data != form.register.confirm_password.data: flash('Passwords do not match!') else: preparedQuery = 'INSERT INTO Users (username, first_name, last_name, password) VALUES(?,?,?,?);' data = (form.register.username.data.lower(), form.register.first_name.data, form.register.last_name.data, generate_password_hash(form.register.password.data)) safe_query(preparedQuery, data) return redirect(url_for('index')) return render_template('index.html', title='Welcome', form=form)
def index(): form = IndexForm() if form.validate_on_submit(): # submit button 1: query if form.submit1.data: number_subj, new_df = query_csv(form) flash('Number of subjects due to your selection: {}'.format(number_subj), 'error') ### IN RED COLOUR!!! return render_template('index.html', form=form, result_pca=None, result_hcl=None) # submit button 2: download if form.submit2.data: number_subj, new_df = query_csv(form) resp = make_response(new_df.to_csv()) resp.headers["Content-Disposition"] = "attachment; filename=export.csv" resp.headers["Content-Type"] = "text/csv" return resp # submit button 3: PCA if form.submit3.data: number_subj, new_df = query_csv(form) fig_pca = pca_cnsvs_ss(new_df) from io import BytesIO import base64 figpcafile = BytesIO() fig_pca.savefig(figpcafile, format='png') figpcafile.seek(0) # rewind to beginning of file figdata_png_pca = base64.b64encode(figpcafile.getvalue()) return render_template('index.html', form=form, result_pca=figdata_png_pca.decode('utf8'), result_hcl=None) # submit button 4: Clustering if form.submit4.data: number_subj, new_df = query_csv(form) fig_hcl = clustering_cnsvs_ss(new_df) from io import BytesIO import base64 fighclfile = BytesIO() fig_hcl.savefig(fighclfile, format='png') fighclfile.seek(0) # rewind to beginning of file figdata_png_hcl = base64.b64encode(fighclfile.getvalue()) return render_template('index.html', form=form, result_pca=None, result_hcl=figdata_png_hcl.decode('utf8')) return render_template('index.html', form=form, result=None)
def index(): global temp_file_url global face_user form = IndexForm() if form.validate_on_submit() and form.submit.data: return redirect(url_for('add_mouth_effect')) if form.validate_on_submit() and form.submit_eyes.data: return redirect(url_for('add_eyes_effect')) if form.validate_on_submit() and form.default.data: return redirect(url_for('default')) temp_file_url = temp_file_url.replace('app/', '') phrase = welcome_phrase(face_user.mood) return render_template('index.html', title='Home', image=temp_file_url, form=form, welcome_phrase=phrase)
def index(): user = User.query.filter_by(username=current_user.username).first() otdel = user.otdel seed = user.seed _, tests, _ = make_test(user, otdel, seed) form = IndexForm() if request.method == 'POST': return redirect(url_for('test')) return render_template('index.html', title='Home', otdel=otdel, tests=tests, form=form)
def index(): indexForm = IndexForm() checkForm = CheckForm() newestday = Date.query.order_by( Date.day.desc()).first() # THis way our newest day is first in table date = str(newestday.day) shares = StockShares.query.filter_by(date=newestday.day).all() indexForm.date.list = ('db_dates') dates = Date.query.order_by(Date.day.desc()).all() if current_user.is_authenticated: usershares = StockShares.query.filter_by(date=date).join( UserShares, UserShares.user_company == StockShares.stockName).filter_by( user_id=current_user.id).all() if indexForm.submitDate.data and indexForm.validate_on_submit(): date = indexForm.date.data shares = StockShares.query.filter_by(date=date).all() usershares = StockShares.query.filter_by(date=date).join( UserShares, UserShares.user_company == StockShares.stockName).filter_by( user_id=current_user.id).all() return render_template('index.html', title="Porzadna praca", indexForm=indexForm, shares=shares, checkForm=checkForm, usershares=usershares, dates=dates) else: if indexForm.submitDate.data and indexForm.validate_on_submit(): date = indexForm.date.data shares = StockShares.query.filter_by(date=date).all() return render_template('index.html', title="Porzadna praca", indexForm=indexForm, shares=shares, checkForm=checkForm, dates=dates)
def home(): form = IndexForm() if request.method == 'POST': char = requests.get("http://chargen:5001/get_chargen") num = requests.get("http://numgen:5002/get_numgen") prize = requests.post("http://prizegen:5003/prize", json={"account_number" : char.text + num.text}) account_number = char.text + num.text account_prize = Prizes(account_number = account_number, prize = prize.text) db.session.add(account_prize) db.session.commit() prizes = Prizes.query.all() return render_template('index.html', form=form, account = char.text+num.text, message = prize.text, prizes = prizes) return render_template('index.html', form=form, message = "")
def index(): if "user" in session.keys(): if session["user"]: return redirect( url_for('stream', username=session["user"], sessionuser=session["user"])) else: session["user"] = None form = IndexForm() if form.login.validate_on_submit(): username_entered = form.login.username.data password_entered = form.login.password.data query = ('SELECT * FROM Users WHERE username=?;', (username_entered, )) user = query_db(query, one=True) if user == None: flash("Username or password incorrect") elif not pbkdf2_sha256.verify(password_entered, user['password']): flash("Username or password incorrect") elif pbkdf2_sha256.verify(password_entered, user['password']): session["user"] = form.login.username.data return redirect( url_for('stream', username=username_entered, sessionuser=session["user"])) elif form.register.validate_on_submit(): username = form.register.username.data password = form.register.password.data encrypt_pswd = pbkdf2_sha256.hash( password ) #Hashes and adds a 16byte salt, by default adds 29000 iterations. query = 'SELECT * FROM Users WHERE username=?;', (username, ) user = query_db(query, one=True) if user == None: query = 'INSERT INTO Users (username, first_name, last_name, password) VALUES(?, ?, ?, ?);', ( form.register.username.data, form.register.first_name.data, form.register.last_name.data, encrypt_pswd) query_db(query, one=True) return redirect(url_for('index')), flash('New user registered!') else: flash('Username already exists.') return render_template('index.html', title='Welcome', form=form)
def index(): form = IndexForm() if form.login.is_submitted() and form.login.submit.data: user = query_db('SELECT * FROM Users WHERE username="******";'.format( form.login.username.data), one=True) if user == None: flash('Sorry, this user does not exist!') elif user['password'] == form.login.password.data: return redirect( url_for('stream', username=form.login.username.data)) else: flash('Sorry, wrong password!') elif form.register.is_submitted() and form.register.submit.data: query_db( 'INSERT INTO Users (username, first_name, last_name, password) VALUES("{}", "{}", "{}", "{}");' .format(form.register.username.data, form.register.first_name.data, form.register.last_name.data, form.register.password.data)) return redirect(url_for('index')) return render_template('index.html', title='Welcome', form=form)
def index(): form = IndexForm() if form.login.is_submitted( ) and form.login.submit.data and form.login.validate_on_submit(): try: user = query_db('SELECT * FROM Users WHERE username=?', form.login.username.data, one=True) if user == None: flash('Sorry, wrong username or password!') elif user['password'] == hash_password(form.login.password.data): login_user(User(user['username'], user['password'], user['id']), remember=form.login.remember_me.data) return redirect( url_for('stream', username=form.login.username.data)) else: flash('Sorry, wrong username or password!') except Exception as e: flash( 'An error has occured, please contact the admin\nError was: {}' .format(e), 'error') elif form.register.is_submitted( ) and form.register.submit.data and form.register.validate_on_submit(): username = sanitizeStr(form.register.username.data) firstname = sanitizeStr(form.register.first_name.data) lastname = sanitizeStr(form.register.last_name.data) password = hash_password(sanitizeStr(form.register.password.data)) flash('Congratulations, {} registered!'.format( sanitizeStr(form.register.username.data))) query_db( 'INSERT INTO Users (username, first_name, last_name, password) VALUES(?, ?, ?, ?)', username, firstname, lastname, password) return redirect(url_for('index')) return render_template('index.html', title='Welcome', form=form)
def index(): form = IndexForm() if form.validate_on_submit(): return redirect(url_for('index'), points = form.points.data, rebounds = form.rebounds.data, assists = form.assists.data, steals = form.steals.data, blocks = form.blocks.data, three = form.threes.data, fgp = form.fgp.data, fga = form.fga.data, ftp = form.ftp.data, fta = form.fta.data, turnovers = form.turnovers.data) return render_template('index.html', title='Home', form=form)
def index(): cur.execute( 'select username, email, type_u from Пользователи where id = %s', (current_user.id, )) user1 = cur.fetchone() st_gr = user1 if user1[2] == 'Студент': cur.execute('select №Группы from Студент where email = %s', (user1[1], )) st_gr = cur.fetchone() user = {'username': user1[0], 'role': user1[2], 'group': st_gr[0]} form = IndexForm() cur.execute( 'select ФИО, №Зачетки,Стипендия,№Группы from Студент order by ФИО') students = cur.fetchall() if user1[2] == 'Студент': cur.execute('select №Зачетки from Студент where ФИО = %s', (user1[0], )) s_number = cur.fetchone() cur.execute( 'select НаучнаяРабота.Название, ТемаНаучнаяРабота.НазваниеТемы, НаучнаяРабота.ФИОНаучрук from НаучнаяРабота, ТемаНаучнаяРабота where НаучнаяРабота.Название = ТемаНаучнаяРабота.НазваниеРаботы and НаучнаяРабота.Название in (select Название from СтудентНаучнаяРабота where №Зачетки = %s);', (s_number)) elif user1[2] == 'Преподаватель': cur.execute( 'select НаучнаяРабота.Название, ТемаНаучнаяРабота.НазваниеТемы, НаучнаяРабота.ФИОНаучрук from НаучнаяРабота, ТемаНаучнаяРабота where НаучнаяРабота.Название = ТемаНаучнаяРабота.НазваниеРаботы and НаучнаяРабота.Название in (select Название from НаучнаяРаботаПрепод where ФИО = %s);', (user1[0], )) w = cur.fetchall() w1 = cur.fetchall() w_prep = cur.fetchall() w_st = cur.fetchall() if user1[2] == 'Преподаватель': cur.execute( 'select НазваниеРаботы, НазваниеТемы from ТемаНаучнаяРабота where НазваниеРаботы in (select Название from НаучнаяРабота where ФИОНаучрук = %s)', (user1[0], )) w1 = cur.fetchall() cur.execute('select * from НаучнаяРаботаПрепод') w_prep = cur.fetchall() cur.execute( 'select СтудентНаучнаяРабота.Название, Студент.ФИО from СтудентНаучнаяРабота, Студент where СтудентНаучнаяРабота.№Зачетки = Студент.№Зачетки' ) w_st = cur.fetchall() if form.validate_on_submit(): if form.submit.data == True: if form.group.data == '': flash('Вы не ввели номер группы!') return redirect('/index') cur.execute('select * from Группа where №Группы = %s;', (form.group.data, )) g = cur.fetchone() if g is None: cur.execute('insert into Группа values (%s);', (form.group.data, )) con.commit() flash('Группа добавлена!') return redirect('/index') else: flash('Такая группа уже существует!') return redirect('/index') elif form.submit_s.data == True: if form.grant.data == '': form.grant.data = 0 if int(form.grant.data) == 0: cur.execute( 'update Студент set Стипендия = %s where №Зачетки = %s', ( None, form.s_num.data, )) else: cur.execute( 'update Студент set Стипендия = %s where №Зачетки = %s', ( form.grant.data, form.s_num.data, )) con.commit() flash('Стипендия изменена!') return redirect('/index') elif form.submit_st_del.data == True: cur.execute('select email from Студент where №Зачетки = %s', (form.st_del_id.data, )) email = cur.fetchone() cur.execute('delete from СтудентНаучнаяРабота where №Зачетки = %s', (form.st_del_id.data, )) cur.execute('delete from Студент where №Зачетки = %s', (form.st_del_id.data, )) cur.execute('delete from Пользователи where email = %s', (email, )) con.commit() elif form.gr_del.data == True: cur.execute('select ФИО from Студент where №Группы = %s', (form.gr_del_num.data, )) st_in_gr = cur.fetchone() if st_in_gr is None: cur.execute('delete from Группа where №Группы = %s', (form.gr_del_num.data, )) con.commit() else: flash('В этой группе еще продолжают учиться студенты!') elif form.prep_del_s.data == True: cur.execute('delete from НаучнаяРаботаПрепод where ФИО = %s', (form.prep_del.data, )) cur.execute( 'select Название from НаучнаяРабота where ФИОНаучрук = %s', (form.prep_del.data, )) prep_del = cur.fetchone() if prep_del is not None: cur.execute( 'delete from СтудентНаучнаяРабота where Название in (select Название from НаучнаяРабота where ФИОНаучрук = %s)', (form.prep_del.data, )) cur.execute( 'delete from Участие where НазваниеРаботы in (select Название from НаучнаяРабота where ФИОНаучрук = %s)', (form.prep_del.data, )) cur.execute( 'delete from ТемаНаучнаяРабота where НазваниеРаботы in (select Название from НаучнаяРабота where ФИОНаучрук = %s)', (form.prep_del.data, )) cur.execute('delete from НаучнаяРабота where ФИОНаучрук = %s', (form.prep_del.data, )) cur.execute('delete from Преподаватель where ФИО = %s', (form.prep_del.data, )) cur.execute('delete from Пользователи where username = %s', (form.prep_del.data, )) flash('Преподаватель %s уволен!', (form.prep_del.data)) cur.execute( 'select ФИО, №Зачетки,Стипендия,№Группы from Студент order by ФИО') students = cur.fetchall() cur.execute('select * from Преподаватель') prep = cur.fetchall() cur.execute('select * from Группа order by №Группы') gr = cur.fetchall() return render_template('index.html', title='Научные работы', user=user, form=form, w=w, w1=w1, students=students, w_prep=w_prep, w_st=w_st, gr=gr, prep=prep)
def register(): form = IndexForm() return render_template('index.html', title='Register', form=form)
def index(): form = IndexForm() return render_template('index.html', title='Scraper via FullContactAPI', form=form)
def saving(): form = IndexForm() if form.validate_on_submit: # 1st API call url = "https://imdb8.p.rapidapi.com/title/find" # gets show from form entry show_to_search = request.values.get('movie_title') querystring = {"q": show_to_search} headers = { 'x-rapidapi-host': "imdb8.p.rapidapi.com", 'x-rapidapi-key': "5a64743a7bmsh79b17ce5d033775p102796jsneae2a4334407" } response = requests.request("GET", url, headers=headers, params=querystring).json() # Grabbing Tconst, title from API call tconst = response['results'][0]['id'].split('/')[2] title = response['results'][0]['title'] # Grab plot plot_url = "https://imdb8.p.rapidapi.com/title/get-plots" plot_querystring = {"tconst": tconst} plot_headers = { 'x-rapidapi-host': "imdb8.p.rapidapi.com", 'x-rapidapi-key': "5a64743a7bmsh79b17ce5d033775p102796jsneae2a4334407" } plot_response = requests.request("GET", plot_url, headers=plot_headers, params=plot_querystring).json() plot = plot_response['plots'][0]['text'] # check if show info is already in DB if not then add it name_exists = db.session.query( db.exists().where(Movies.tconst == tconst)).scalar() if not name_exists: movie_info = Movies(tconst=tconst, title=title, plot=plot) db.session.add(movie_info) db.session.commit() # 2nd API Call to "get similar show" tconst_url = "https://imdb8.p.rapidapi.com/title/get-more-like-this" tconst_querystring = { "currentCountry": "US", "purchaseCountry": "US", "tconst": tconst } tconst_headers = { 'x-rapidapi-host': "imdb8.p.rapidapi.com", 'x-rapidapi-key': "5a64743a7bmsh79b17ce5d033775p102796jsneae2a4334407" } tconst_response = requests.request("GET", tconst_url, headers=tconst_headers, params=tconst_querystring).json() # Gets responses, takes 1st element, splits and takes the tconstant # of show that is similar to initially searched show similar_show_tconst = tconst_response[0].split('/')[2] # if similar_show (tconst) is in DB # query info from DB instead of calling API name_exists = db.session.query( db.exists().where(Movies.tconst == similar_show_tconst)).scalar() if name_exists: title_name = Movies.query.filter_by( tconst=similar_show_tconst).first() similar_show = title_name.title similar_plot = title_name.plot return render_template('display.html', title1=similar_show, plot=similar_plot) else: # 3rd API call only if needed final_url = "https://imdb8.p.rapidapi.com/title/get-plots" final_querystring = {"tconst": similar_show_tconst} final_headers = { 'x-rapidapi-host': "imdb8.p.rapidapi.com", 'x-rapidapi-key': "5a64743a7bmsh79b17ce5d033775p102796jsneae2a4334407" } final_response = requests.request("GET", final_url, headers=final_headers, params=final_querystring).json() similar_show_title1 = final_response['base']['title'] similar_show_plot = final_response['plots'][0]['text'] # Save this similar show in DB too to reduce the amount of overall API calls used # check if show info is already in DB if not then add it name_exists = db.session.query(db.exists().where( Movies.tconst == similar_show_tconst)).scalar() if not name_exists: similar_show_info = Movies(tconst=similar_show_tconst, title=similar_show_title1, plot=similar_show_plot) db.session.add(similar_show_info) db.session.commit() return render_template('display.html', title1=similar_show_title1, plot=similar_show_plot)
def index(): form = IndexForm() return render_template('index2.html', title='Home', form=form)
def index_submit(): form = IndexForm() if request.method == 'POST': # check if the post request has the file part if 'file' not in request.files: flash('No file part') return redirect(request.url) file = request.files['file'] if file.filename == '': flash('No file selected for uploading') return redirect(request.url) if file and allowed_file(file.filename): filename = secure_filename(file.filename) file.save(os.path.join(current_dir, "tmp", filename)) else: flash('Allowed file types are txt or csv') return redirect(request.url) api_key = form.api_key.data if form.validate_on_submit(): ################################## with open(os.path.join(current_dir, "tmp", filename)) as input_file, open( 'output.csv', 'w') as output: csv_reader = csv.reader(input_file, delimiter=',') csv_out = csv.writer(output, delimiter=',') csv_out.writerow(column_names) # line_count = 0 for row in csv_reader: if row: email = row[0] # line_count += 1 # if line_count%100 == 0: # time.sleep(30) try: # response = call_fullcontact(email, api_key) req = urllib.request.Request( 'https://api.fullcontact.com/v3/person.enrich' ) req.add_header('Authorization', 'Bearer {}'.format(api_key)) data = json.dumps( {"email": "{}".format(email)}) response = urllib.request.urlopen( req, data.encode()) x = response.read().decode('utf-8') xx = json.loads(x) # f = csv.writer(open("output.csv", "w")) # f.writerow(column_names) csv_out.writerow(get_csv_row(xx, email)) except urllib.error.HTTPError as e: print('API HTTPrequest handling error{0}: {1}'. format(e.getcode(), email)) if e.getcode() == 403: time.sleep(300) print( 'rised x-limit, so please for a while...' ) xx = {} csv_out.writerow(get_csv_row(xx, email)) except urllib.error.URLError as e: # Not an HTTP-specific error (e.g. connection refused) # ... print('URLError: {0}: {1}'.format( e.reason, email)) xx = {} csv_out.writerow(get_csv_row(xx, email)) flash('Hello, Success!') ################################## else: flash('Error: All Fields are Required') # load registration template return render_template('index.html', title='Scraper via FullContactAPI', form=form)
def index(): # checks cookies for user user = query_db('SELECT * FROM Users WHERE username="******";'.format( request.cookies.get('username')), one=True) if session.get('login_attempts') == None: # if the login attempts session data doesnt exist it makes one. session['login_attempts'] = int(0) session['login_block'] = datetime.now() if user == None: # if cookie didnt contain user it display the normal login form = IndexForm() if form.login.validate_on_submit() and form.login.submit.data: if datetime.now() > session.get('login_block'): if int(session.get('login_attempts')) >= 4: flash( 'You have failed too many login attempts, try again in 30 seconds' ) session['login_block'] = datetime.now() + timedelta( seconds=30) session['login_attempts'] = int(0) else: user = query_db( 'SELECT * FROM Users WHERE username="******";'.format( form.login.username.data), one=True) if user == None: session['login_attempts'] = int( session.get('login_attempts') + 1) flash('Sorry, This username or password is incorrect') elif check_password_hash(user['password'], form.login.password.data): session['username'] = form.login.username.data session['password'] = user['password'] if form.login.remember_me.data == True: response = make_response( redirect( url_for( 'stream', username=form.login.username.data))) response.set_cookie('username', form.login.username.data) response.set_cookie('password', user['password']) return response return redirect( url_for('stream', username=form.login.username.data)) else: session['login_attempts'] = int( session.get('login_attempts') + 1) flash('Sorry, This username or password is incorrect') else: flash( "you are still blocked from logging in, please wait a bit longer" ) # if register form is submitted elif form.register.validate_on_submit() and form.register.submit.data: user_reg = query_db( 'SELECT * FROM Users WHERE username="******";'.format( form.register.username.data), one=True) if user_reg == None: query_db( 'INSERT INTO Users (username, first_name, last_name, password) VALUES("{}", "{}", "{}", "{}");' .format( form.register.username.data, form.register.first_name.data, form.register.last_name.data, generate_password_hash(form.register.password.data))) flash('User ' + form.register.username.data + ' created') return redirect(url_for('index')) else: flash("This username is already taken") return render_template('index.html', title='Welcome', form=form) elif user['password'] == request.cookies.get('password'): # logs you in if the cookie had a valid login session['username'] = request.cookies.get('username') session['password'] = request.cookies.get('password') return redirect( url_for('stream', username=request.cookies.get('username'))) else: # if the cookie has bad login data it will redirect back to index flash('Sorry, The login data in the cookie is incorrect') response = make_response(redirect(url_for('index'))) # deletes the cookie response.set_cookie('username', "", expires=0) response.set_cookie('password', "", expires=0) return response