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

Fix db handler #14

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 3 additions & 1 deletion .replit
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@

modules = ["python-3.12", "postgresql-16"]
run = "streamlit run --server.headless true main.py"

[nix]
channel = "stable-24_05"

[deployment]
run = ["sh", "-c", "streamlit run --server.headless true --server.baseUrlPath situatelearning main.py"]
run = ["sh", "-c", "streamlit run --server.headless true main.py"]
deploymentTarget = "cloudrun"
deploymentName = "situatelearning"
customDomain = "beta.chergpt.sg"

[[ports]]
localPort = 8501
Expand Down
7 changes: 2 additions & 5 deletions .streamlit/config.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@

[theme]
base="dark"
primaryColor="#75F8CC"

[server]
headless = true
baseUrlPath = "situatelearning"

[theme]
base="dark"
primaryColor="#75F8CC"
Binary file added attached_assets/image_1736261562637.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added attached_assets/image_1736261779161.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added attached_assets/image_1736261904799.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions database.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def init_db():

def save_feedback(session_id, search_term, nps_score=None, email=None, comments=None):
"""Save feedback to PostgreSQL database"""
conn = None
cur = None
try:
conn = psycopg2.connect(os.environ['DATABASE_URL'])
cur = conn.cursor()
Expand All @@ -48,6 +50,10 @@ def save_feedback(session_id, search_term, nps_score=None, email=None, comments=
)

conn.commit()
except Exception as e:
print(f"Error saving feedback: {e}")
finally:
cur.close()
conn.close()
if cur is not None:
cur.close()
if conn is not None:
conn.close()
Loading