Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import streamlit_authenticator as stauth
|
3 |
+
import yaml
|
4 |
+
from yaml.loader import SafeLoader
|
5 |
+
|
6 |
+
# Load configuration for authentication
|
7 |
+
with open('config.yaml') as file:
|
8 |
+
config = yaml.load(file, Loader=SafeLoader)
|
9 |
+
|
10 |
+
authenticator = stauth.Authenticate(
|
11 |
+
config['credentials'],
|
12 |
+
config['cookie']['name'],
|
13 |
+
config['cookie']['key'],
|
14 |
+
config['cookie']['expiry_days'],
|
15 |
+
config['preauthorized']
|
16 |
+
)
|
17 |
+
|
18 |
+
st.set_page_config(page_title="Ayurvedic Healthcare Platform", layout="wide")
|
19 |
+
|
20 |
+
def main():
|
21 |
+
st.title("AI-Powered Ayurvedic Healthcare Platform")
|
22 |
+
|
23 |
+
st.write("Welcome to our innovative Ayurvedic wellness platform!")
|
24 |
+
|
25 |
+
col1, col2 = st.columns(2)
|
26 |
+
|
27 |
+
with col1:
|
28 |
+
st.subheader("New to our platform?")
|
29 |
+
if st.button("Sign Up"):
|
30 |
+
st.session_state['signup'] = True
|
31 |
+
|
32 |
+
with col2:
|
33 |
+
st.subheader("Already have an account?")
|
34 |
+
name, authentication_status, username = authenticator.login('Login', 'main')
|
35 |
+
|
36 |
+
if st.session_state.get('signup', False):
|
37 |
+
with st.form("signup_form"):
|
38 |
+
st.subheader("Sign Up")
|
39 |
+
new_username = st.text_input("Username")
|
40 |
+
new_password = st.text_input("Password", type="password")
|
41 |
+
role = st.selectbox("I am a", ["Patient", "Doctor"])
|
42 |
+
if st.form_submit_button("Create Account"):
|
43 |
+
# Here you would typically add the new user to your database
|
44 |
+
st.success(f"Account created for {new_username} as a {role}!")
|
45 |
+
if role == "Patient":
|
46 |
+
st.info("You've received $500 USD in your internal wallet.")
|
47 |
+
st.session_state['signup'] = False
|
48 |
+
|
49 |
+
if st.session_state.get("authentication_status"):
|
50 |
+
authenticator.logout('Logout', 'main')
|
51 |
+
st.write(f'Welcome *{st.session_state["name"]}*')
|
52 |
+
st.info("Please navigate to the appropriate module using the sidebar.")
|
53 |
+
elif st.session_state.get("authentication_status") is False:
|
54 |
+
st.error('Username/password is incorrect')
|
55 |
+
|
56 |
+
if __name__ == "__main__":
|
57 |
+
main()
|