import streamlit as st 
import setting as sg
from captcha import random_str as rs

def login():
	st.title("Login Page")
	list_given1 = sg.sheet.col_values(1)
	list_given2 = sg.sheet.col_values(2)
	username = st.text_input("Username:")
	password = st.text_input(type="password",label="Password:")
	t = st.checkbox("I agree to this")
	count = 0 
	for i in range(0,len(list_given1)):
		if list_given1[i] == username:
			count = i
			break
		else :
			var = 1	

	"""temp1 = st.success(rs)
	st.write(temp1)
	temp2 = st.text_input("Captcha:")
	st.write(temp2)
	temp2 = int(temp2)
	t = False
	if temp1 ==temp2:
		t = True
	st.write(t)"""
	
				

	if st.button('Login') and username !="\0" and password !="\0" and t == True :
		if username == list_given1[count] and password == list_given2[count]:
			st.write("""
				:sunglasses: Hi Mr.*{}*
				""".format(username))
		elif var==1:
			st.error("Username Doesnt Exist")

		

		 








if __name__ == '__main__':
	login()
