Spaces:
Build error
Build error
| import streamlit as st | |
| from signup import signup | |
| from login import login | |
| from query import run_query_app | |
| from streamlit_option_menu import option_menu | |
| # this the fucntion to show the greater value | |
| def myFUnc(): | |
| print('moazzam riaz') | |
| i = 1 | |
| if i == 0: | |
| print('the number is geater than the value') | |
| else: | |
| print('the number is not grate') | |
| # this the recursion function to calculate the factorial | |
| def thiFunc(n): | |
| input('enter to calculate factorial', n) | |
| if n == 0 or n == 1: | |
| return 1 | |
| else: | |
| return n * thiFunc(n - 1) | |
| # this the function to including inheritaNCE and method overloading polymorphism | |
| class Animal: | |
| def sound(): | |
| print('aniaml sound') | |
| class Dog(Animal): | |
| def sound(): | |
| print('boww bpoww') | |
| # this class is with a constructor which will be called automaticlly when the object is created | |
| class Cat(Animal): | |
| def sound(): | |
| print('meoww meoww') | |
| def __init__(self, a, b): | |
| self.a = a, | |
| self.b = b, | |
| def main(): | |
| st.title("Document Query System") | |
| # Step 1: Initialize session state variables | |
| if 'username' not in st.session_state: | |
| st.session_state['username'] = None | |
| if 'login_successful' not in st.session_state: | |
| st.session_state['login_successful'] = False | |
| # Step 2: Check if user is logged in | |
| if st.session_state['username'] is None: | |
| # User is not logged in, display login and signup options | |
| selection = option_menu( | |
| menu_title="Main Menu", | |
| options=["Login", "Signup"], | |
| icons=["person", "person"], | |
| menu_icon="cast", | |
| default_index=1 | |
| ) | |
| if selection == "Login": | |
| st.session_state['username'] = login() | |
| if st.session_state['username']: | |
| st.session_state['login_successful'] = True | |
| elif selection == "Signup": | |
| signup() | |
| # Step 3: Check if user is logged in successfully | |
| if 'login_successful' in st.session_state and st.session_state['login_successful']: | |
| # User is logged in, display welcome message and query page | |
| if 'username' in st.session_state and st.session_state['username']: | |
| st.subheader(f"Welcome, {st.session_state['username']}!") | |
| run_query_app(st.session_state['username']) | |
| if st.sidebar.button("Logout"): | |
| st.session_state['username'] = None | |
| st.session_state['login_successful'] = False | |
| st.empty() # Clear the contents of the page | |
| if __name__ == '__main__': | |
| main() | |