-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
101 lines (76 loc) · 3.12 KB
/
main.py
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
97
98
99
100
import streamlit as st
import cx_Oracle
from Project import signing, gallary
from Project.mailing import send_feedback_email
from Project.theme_utils import set_theme
from dotenv import load_dotenv
from Project.db_utils import get_oracle_connection_string
load_dotenv()
# Construct the connection string using the function
connection_string = get_oracle_connection_string()
# Set your Oracle database connection details
db_username = "m"
db_password = "00"
db_host = "localhost"
db_port = "1521"
db_service_name = "XE" # Assuming XE is the service name based on your tnsnames.ora
# Construct the connection string
connection_string = f"{db_username}/{db_password}@{db_host}:{db_port}/{db_service_name}"
try:
# Establish the connection
connection = cx_Oracle.connect(connection_string)
# Check if the connection is successful
if connection:
st.success("Connected to the Oracle database.")
else:
st.error("Failed to connect to the Oracle database.")
except cx_Oracle.DatabaseError as e:
error, = e.args
if error.code == 12514:
st.error("ORA-12514: TNS:listener does not currently know of service requested in connect descriptor.")
else:
st.error(f"DatabaseError: {error}")
# Day and Night Theme Toggle
if st.button("Toggle Theme"):
current_theme = st.session_state.get("theme", "day")
new_theme = "night" if current_theme == "day" else "day"
set_theme(new_theme)
st.session_state.theme = new_theme
# ... (existing code)
# Sidebar navigation
page = st.sidebar.selectbox("Select Page", ["Home", "Signing", "DNA Gallery", "Oracle Page", "Mailing"])
if page == "Home":
# Display image at the beginning with caption
st.markdown('<div class="image-container">', unsafe_allow_html=True)
st.image("https://hms.harvard.edu/sites/default/files/media/DNA-850.jpg", width=None, caption="DNA Structure")
st.markdown("</div>", unsafe_allow_html=True)
# Page title with a gradient background
st.title("Helical Hues Haven")
st.markdown('<div class="title-container"></div>', unsafe_allow_html=True)
elif page == "Signing":
# Call the signing.py file in the project directory
signing.show()
elif page == "DNA Gallery":
# Call the display_gallery function from gallary.py
gallary.display_gallery()
elif page == "Oracle Page":
st.write("Oracle Page - Database interaction code removed")
elif page == "Mailing":
st.header("Feedback")
# Input for user's email address
sender_email = st.text_input("Your Email Address:")
# Text area for feedback
feedback_text = st.text_area("Enter your feedback:")
# Button to send email
if st.button("Send Email"):
# Check if both email and feedback are provided
if sender_email and feedback_text:
# Send feedback email
if send_feedback_email(sender_email, feedback_text):
st.success("Email sent successfully!")
else:
st.error("Error sending email. Please try again later.")
else:
st.error("Please provide both your email address and feedback.")
else:
st.write("Page not found")