# source .venv/bin/activate # streamlit run <>.py import streamlit as st import app_utils as util from pathlib import Path from PIL import Image from io import BytesIO import requests import time st.set_page_config(page_title="SAnDL", page_icon="🩴", layout="wide", initial_sidebar_state="collapsed") # Example URL image_url = "https://media.discordapp.net/attachments/1013678935231442944/1175575324210249740/sandll2.png?ex=656bbad6&is=655945d6&hm=d8f4a93a7c3ae90978f820093e2e7c17c18b6125546255afaaeca8ed6716bd4d&=&width=2268&height=486" # Open image from URL response = requests.get(image_url) img = Image.open(BytesIO(response.content)) # close taskbar, page margin, ... st.markdown(""" """, unsafe_allow_html=True) logincol1, logincol2, logincol3 = st.columns([1, 8, 1]) with logincol2: # logo st.image(img) # caption st.markdown('
' + "Developing anomaly detection systems for filtration of large language model prompts." + '
', unsafe_allow_html=True) #login form profilecontainer = st.container() login_form = profilecontainer.form('Login') username = login_form.text_input('Username').lower() st.session_state['username'] = username password = login_form.text_input('Password', type='password') if login_form.form_submit_button('Login'): st.session_state.pop('FormSubmitter:Login-Login', None) # deletes all keys from previous logins for key in st.session_state.keys(): if (key != 'username'): st.session_state.pop(key) res = requests.post("https://sandl-backend-ny3lmzb4dq-uc.a.run.app/login", json={"email": username, "password": password}) error = res.status_code # login validation if error == 200: st.session_state['userdata'] = res.json()["jwt"] st.success('Login Successful!', icon="✅") util.switch_page("query") # username exists in db, but password is incorrect elif error == 400: st.error('Incorrect Password.', icon="🚨") # makes new account elif error == 500: st.info('Account Not Found: New account created.', icon="ℹ️") res = requests.post("https://sandl-backend-ny3lmzb4dq-uc.a.run.app/sign_up", json={"email": username, "password": password}) res = requests.post("https://sandl-backend-ny3lmzb4dq-uc.a.run.app/login", json={"email": username, "password": password}) st.session_state['userdata'] = res.json()["jwt"] requests.post("https://sandl-backend-ny3lmzb4dq-uc.a.run.app/add_api_key", json={"jwt": st.session_state['userdata']}) time.sleep(.5) util.switch_page("query")