Spaces:
Running
Running
File size: 1,874 Bytes
90cb4f4 2b2f0d1 90cb4f4 0759822 0960577 dd7da04 0960577 dd3763f 0960577 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
import streamlit as st
import os
from dotenv import load_dotenv
from views.continue_survey import continue_survey_screen
from db.crud import read
load_dotenv()
VALIDATION_CODE = os.getenv("VALIDATION_CODE")
def validate_username(username: str) -> bool:
return bool(username.strip())
def validate_code(input_code: str) -> bool:
"""Validate the entered code against the hardcoded validation code"""
return input_code.strip() == VALIDATION_CODE
def welcome_screen():
"""Display the welcome screen and direct users accordingly."""
with st.container():
st.markdown("""<style> .st-emotion-cache-1jicfl2 {width: 50%;} </style>""", unsafe_allow_html=True)
st.title("Welcome to the Feedback Survey")
username_input = st.text_input("Enter your first name and press TAB. Usernames are case-sensitive.")
validation_code_input = st.text_input("Enter the validation code to proceed and press ENTER:")
next_button = st.button("Next")
footer_html = """<div style='text-align: center; background-color:#ECECEC;padding:3rem;'> <p
style='font-size: large;'>⚠️ Note: This is still a work in progress. <br> If you encounter bugs or issues
please create a Pull Request and we will look into it.</br></p> </div> """
st.markdown(footer_html, unsafe_allow_html=True)
if (username_input and validation_code_input) or next_button:
if validate_username(username_input) and validate_code(validation_code_input):
st.session_state.username = username_input
else:
if not validate_username(username_input):
st.warning("Invalid username. Please check and try again.")
if not validate_code(validation_code_input):
st.warning("Invalid validation code. Please check and try again.")
|