Summary
Hello community!
I’m learning to deal with the application and I had a doubt.
I made a kind of login screen, nothing too complicated, a form with a button that validates whether or not the user exists in the bank to login.
The logic worked fine, I am able to authenticate and log in, but I have difficulty changing the page after login.
My initial idea is to have the login screen as the main page, after login I will have a page with several other contents and sidebars with projects and functions.
the only thing I managed and after login to run something on the same page, below the login field.
Can anyone help me with an idea of how to finish this project of mine or say if there is such a possibility?
I ended up watching several videos about similar projects, but I found it a bit confusing for my understanding and it kept me from focusing on my initial idea.
Thank you for your help!!!
Steps to reproduce
Code snippet:
import streamlit as st
from streamlit_extras.switch_page_button import switch_page
from conexao import *
import time
from streamlit_extras.stoggle import stoggle
banco = DataBase('autenticacao.db')
col1, col2, col3 = st.columns([1,2,1])
with col2:
with st.form(key='autenticacao'):
input_login = st.text_input(label='Usuario')
input_senha = st.text_input(label='Senha',type="password")
input_botao = st.form_submit_button('Fazer Login')
# with col1:
# with st.form(key='autenticacao'):
validar_usuario = banco.usuario_existe(input_login)
login = banco.autenticar_usuario(input_login)
senha = banco.autenticar_senha(input_login)
col_1, col_2, col_3 = st.columns([1,2,1])
with col_2:
if input_botao:
if validar_usuario == True:
if login == input_login and senha == input_senha:
with st.spinner('Autenticando Usuario'):
time.sleep(1)
st.success('Logado!!!')
st.balloons()
switch_page("teste")
else:
with st.spinner('Autenticando Usuario'):
time.sleep(1)
st.error('Usuario ou senha invalidos!', icon="🚨")
else:
st.error('Usuario não Cadastrado')
if st.button("Lembrei!"):
run_expensive_function()