Spaces:
Sleeping
Sleeping
File size: 3,061 Bytes
d03e822 |
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 |
import streamlit as st
from time import sleep
from navigation import make_sidebar
import yaml
import datetime
import pytz
import os
make_sidebar()
st.title("Welcome to Job Finder")
hide_st_style = """
<style>
#MainMenu {visibility: hidden;}
footer {visibility: hidden;}
header {visibility: hidden;}
</style>
"""
st.markdown(hide_st_style, unsafe_allow_html=True)
sign_in, sign_up = st.tabs(["Sign In", "Sign Up"])
with sign_in:
username = st.text_input("Username")
password = st.text_input("Password", type="password")
password = password.strip()
if st.button("Sign in", type="primary"):
with open('data/users/users.yaml', 'r') as file:
config = yaml.safe_load(file)
# print(config)
if username in list(config.keys()) and password == config[username]["password"]:
st.session_state.logged_in = True
st.session_state.user=username
st.success("Logged in successfully!")
sleep(0.5)
st.switch_page("pages/page1.py")
else:
st.error("Incorrect username or password")
with sign_up:
name = st.text_input("Full name")
username = st.text_input("Username",key="signup_user")
password = st.text_input("Password", type="password",key="Signup_pass")
if st.button("Sign Up", type="primary"):
with open('data/users/users.yaml', 'r') as file:
config = yaml.safe_load(file)
# new_user = {"username":username,"password":password}
if username and password and name:
if username in list(config.keys()):
st.warning("Username is already taken !!")
else:
user_info = {"password":password,
"time":datetime.datetime.now(pytz.timezone('Asia/Kolkata')),
"full_name":name,
"phone_no":0,
"what_app_no":0}
config[username] = user_info
# Define the folder name
folder_name = f'data/users/individuals/{username}'
# Create the folder if it doesn't already exist
status = {}
status[username] = user_info
if not os.path.exists(folder_name):
os.mkdir(folder_name)
#update the user info in global user
with open('data/users/users.yaml', 'w') as file:
yaml.dump(config, file, default_flow_style=False)
#Save user info as status file
with open(f'data/users/individuals/{username}/status.yaml', 'w') as file:
yaml.dump(status, file, default_flow_style=False)
if os.path.exists(folder_name):
st.info("Your account has been made successfully.")
st.success("Please login to continue")
else:
st.warning("Provide valid username and password") |