Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,8 +1,9 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
import
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
|
|
|
| 6 |
|
| 7 |
def main():
|
| 8 |
st.set_page_config(page_title="Auto Assist Chatbot", layout="wide")
|
|
@@ -50,6 +51,19 @@ def main():
|
|
| 50 |
unsafe_allow_html=True
|
| 51 |
)
|
| 52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 53 |
if st.session_state.logged_in:
|
| 54 |
if st.sidebar.button('Back to Login'):
|
| 55 |
st.session_state.logged_in = False
|
|
@@ -67,11 +81,8 @@ def main():
|
|
| 67 |
if st.button('Signup'):
|
| 68 |
if password_signup == confirm_password_signup:
|
| 69 |
if is_valid_input(username_signup, password_signup):
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
st.success('Signup successful!')
|
| 73 |
-
else:
|
| 74 |
-
st.error('Signup failed. Please try again.')
|
| 75 |
else:
|
| 76 |
st.error('You are not able to use "autoassist chatbot".')
|
| 77 |
else:
|
|
@@ -84,8 +95,7 @@ def main():
|
|
| 84 |
|
| 85 |
if st.button('Login'):
|
| 86 |
if is_valid_input(username_login, password_login):
|
| 87 |
-
|
| 88 |
-
if response.status_code == 200:
|
| 89 |
st.session_state.logged_in = True
|
| 90 |
st.experimental_rerun()
|
| 91 |
else:
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import os
|
| 3 |
+
import sqlite3
|
| 4 |
+
from home import show_home_page
|
| 5 |
+
from auth import signup, login
|
| 6 |
+
import database # Ensure database initialization
|
| 7 |
|
| 8 |
def main():
|
| 9 |
st.set_page_config(page_title="Auto Assist Chatbot", layout="wide")
|
|
|
|
| 51 |
unsafe_allow_html=True
|
| 52 |
)
|
| 53 |
|
| 54 |
+
# Function to create a connection to the SQLite database
|
| 55 |
+
def create_connection():
|
| 56 |
+
db_path = os.path.join(os.path.dirname(__file__), 'database.db')
|
| 57 |
+
conn = sqlite3.connect(db_path)
|
| 58 |
+
return conn
|
| 59 |
+
|
| 60 |
+
def is_valid_input(username, password):
|
| 61 |
+
prefix = "autoassist"
|
| 62 |
+
return username.startswith(prefix) and password.startswith(prefix)
|
| 63 |
+
|
| 64 |
+
# Ensure table creation
|
| 65 |
+
database.create_table()
|
| 66 |
+
|
| 67 |
if st.session_state.logged_in:
|
| 68 |
if st.sidebar.button('Back to Login'):
|
| 69 |
st.session_state.logged_in = False
|
|
|
|
| 81 |
if st.button('Signup'):
|
| 82 |
if password_signup == confirm_password_signup:
|
| 83 |
if is_valid_input(username_signup, password_signup):
|
| 84 |
+
signup(username_signup, password_signup)
|
| 85 |
+
st.success('Signup successful!')
|
|
|
|
|
|
|
|
|
|
| 86 |
else:
|
| 87 |
st.error('You are not able to use "autoassist chatbot".')
|
| 88 |
else:
|
|
|
|
| 95 |
|
| 96 |
if st.button('Login'):
|
| 97 |
if is_valid_input(username_login, password_login):
|
| 98 |
+
if login(username_login, password_login):
|
|
|
|
| 99 |
st.session_state.logged_in = True
|
| 100 |
st.experimental_rerun()
|
| 101 |
else:
|