Spaces:
Sleeping
Sleeping
File size: 2,564 Bytes
19aa68f |
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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
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()
|