Skip to content

Commit

Permalink
feat: Added login page!
Browse files Browse the repository at this point in the history
  • Loading branch information
amindadgar committed Mar 6, 2024
1 parent 727a003 commit 5f218f0
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.env
__pycache__
environment/*
config.yaml
main.ipynb
31 changes: 25 additions & 6 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
import streamlit as st
from utils.mongo import MongoSingleton
from utils.process_guild_data import process_guild_data
from streamlit_authenticator import Authenticate
import yaml
from yaml.loader import SafeLoader


# @st.cache_data
def load_guilds_latest_date_df():
client = MongoSingleton.get_instance().client

Expand Down Expand Up @@ -35,8 +37,25 @@ def load_guilds_latest_date_df():


logging.basicConfig(level=logging.INFO)

st.subheader("MongoDB data Analytics")
load_guilds_latest_date_df()
# df = process_df(df)
# st.dataframe(df, use_container_width=True, hide_index=True)
st.subheader("TogetherCrew's Amin Panel")
with open("config.yaml") as file:
config = yaml.load(file, Loader=SafeLoader)

authenticator = Authenticate(
config["credentials"],
config["cookie"]["name"],
config["cookie"]["key"],
config["cookie"]["expiry_days"],
config["preauthorized"],
)
name, authentication_status, username = authenticator.login()

if authentication_status:
authenticator.logout("Logout", "main")
st.write(f"Welcome *{name}*")
# st.title('Some content')
load_guilds_latest_date_df()
elif authentication_status == False:
st.error("Username/password is incorrect")
elif authentication_status == None:
st.warning("Please enter your username and password")
13 changes: 13 additions & 0 deletions config.yaml.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
credentials:
usernames:
jsmith:
email: [email protected]
name: John Smith
password: abc # To be replaced with hashed password
cookie:
expiry_days: 30
key: random_signature_key # Must be string
name: random_cookie_name
preauthorized:
emails:
- [email protected]
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
streamlit
streamlit-authenticator
numpy
pandas
matplotlib
Expand Down

0 comments on commit 5f218f0

Please sign in to comment.