Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

-aw added login sys 2352hrs 23/4 #1

Merged
merged 1 commit into from
Apr 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import streamlit as st
import pandas as pd
import numpy as np
import json
from streamlit_option_menu import option_menu


def main():
st.title("Welcome to My Academic Record")
st.markdown("<p><TT>Designed and Developed by <a style='text-decoration:none;color:red' target='_blank' href='https://github.com/sasivatsal7122'>B.Sasi Vatsal</a></TT></p>", unsafe_allow_html=True)
st.caption("20L31A5413 , Department of AI&DS")

user_option = option_menu(None, ["Sign-In", "Sign-Up"],
icons=['box-arrow-in-left', 'box-arrow-in-right'],
menu_icon="cast", default_index=0, orientation="horizontal")


if user_option=='Sign-Up':
st.header("Haven't Sign up yet?")
sign_up_username = st.text_input("Enter your college roll number: ",'20L31A5413')
sign_up_password = st.text_input("Enter Your Password : ",type="password")
create_acc = st.button("Create My Account")
if create_acc:
f = open('user_creds/users_cred.json')
log_in_creds = json.load(f)

ids = len(log_in_creds['Entries'])

new_user_data = {"User name":f"{sign_up_username}",
"Password": f"{sign_up_password}",
"ID": f"{ids + 1}"
}

with open('user_creds/users_cred.json','r+') as file:
file_data = json.load(file)
log_in_creds['Entries'].append(new_user_data)
file_data.update(log_in_creds)
file.seek(0)
json.dump(file_data, file, indent = 4)
st.balloons()
st.success("Your Account Has been created Successfully...")
else:
st.header("Log In here")
username = st.text_input("Enter your college roll number: ",'20L31A5413',key='login')
password = st.text_input("Enter Your Password : ",type="password",key='login')
log_in_btn = st.button("Log In")
if log_in_btn:
f = open('user_creds/users_cred.json')
log_in_creds = json.load(f)
for e in log_in_creds['Entries']:
if username == e['User name']:

if password == e['Password']:
st.success("User Authenctication Success..Redirecting to Dashboard..")
break
else:
st.error("Wrong Password...User Authenctication Failed")
break

elif int(e['ID'])<len(log_in_creds['Entries']):
continue
else:
st.error(f"No User found with user name '{username}', try sign-up")

if __name__=="__main__":
main()
5 changes: 0 additions & 5 deletions test.txt

This file was deleted.

19 changes: 19 additions & 0 deletions user_creds/users_cred.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"Entries": [
{
"User name": "20L31A5413",
"Password": "sasivatsal",
"ID": "1"
},
{
"User name": "20L31A5413",
"Password": "saimowli",
"ID": "2"
},
{
"User name": "20L31A5413",
"Password": "saimowli",
"ID": "3"
}
]
}