From a75e48f960079816b6d55d2cb46ac9e5071ef144 Mon Sep 17 00:00:00 2001 From: Gautam-7-7 <140533905+Gautam-7-7@users.noreply.github.com> Date: Thu, 9 Jul 2026 16:43:14 +0530 Subject: [PATCH] Fix: dark mode theme, autocomplete dropdown UI, and chatbot server bypass on port 5001 --- .gitignore | 3 ++- Frontend/Analysis/analysis.css | 35 ++++++++++++++++++++++++---------- Frontend/style.css | 2 +- Frontend/theme.js | 12 ++++++++++++ backend/alertsystem.py | 23 +++++++++++++++------- requirements.txt | 5 +++++ 6 files changed, 61 insertions(+), 19 deletions(-) create mode 100644 requirements.txt diff --git a/.gitignore b/.gitignore index 71dfa08..ee032de 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,5 @@ .idea/ __pycache__/ *.pyc -.env \ No newline at end of file +.env +venv/ \ No newline at end of file diff --git a/Frontend/Analysis/analysis.css b/Frontend/Analysis/analysis.css index a628a76..4ee8c7d 100644 --- a/Frontend/Analysis/analysis.css +++ b/Frontend/Analysis/analysis.css @@ -165,20 +165,15 @@ body::before { top: calc(100% + 6px); left: 0; width: 100%; - display: block; - - background: #1e293b; - border: 2px solid red; - + background: rgba(26, 31, 46, 0.95); + backdrop-filter: blur(12px); + border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 12px; max-height: 220px; - overflow-y: auto; - z-index: 999999; - - box-shadow: 0 10px 25px rgba(0,0,0,0.5); + box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4); } .city-suggestions.hidden { @@ -188,12 +183,32 @@ body::before { .city-suggestion-item { padding: 12px 14px; cursor: pointer; - color: white; + color: var(--text-primary, #ffffff); border-bottom: 1px solid rgba(255, 255, 255, 0.05); + font-size: 0.9rem; + transition: background-color 0.2s ease, color 0.2s ease; } .city-suggestion-item:hover { background: rgba(56, 189, 248, 0.15); + color: #ffffff; +} + +/* Light mode styles for autocomplete suggestions */ +[data-theme="light"] .city-suggestions { + background: rgba(255, 255, 255, 0.98); + border: 1px solid rgba(0, 0, 0, 0.1); + box-shadow: 0 12px 30px rgba(0, 0, 0, 0.08); +} + +[data-theme="light"] .city-suggestion-item { + color: #0f172a; + border-bottom: 1px solid rgba(0, 0, 0, 0.05); +} + +[data-theme="light"] .city-suggestion-item:hover { + background: rgba(3, 105, 161, 0.08); + color: #0369a1; } .city-autocomplete { diff --git a/Frontend/style.css b/Frontend/style.css index ddf221e..113f674 100644 --- a/Frontend/style.css +++ b/Frontend/style.css @@ -1237,6 +1237,7 @@ body.light-mode .navbar { text-align: center; justify-content: center; } +} /* Capability cards — same white-alpha issue */ [data-theme="light"] .capability-card { @@ -1291,7 +1292,6 @@ body.light-mode .navbar { [data-theme="light"] .footer-links a:hover { color: #0369a1; } -} /* Scroll to Top Button */ #scrollTopBtn, diff --git a/Frontend/theme.js b/Frontend/theme.js index d838333..18492a5 100644 --- a/Frontend/theme.js +++ b/Frontend/theme.js @@ -12,6 +12,17 @@ if (!btn || !icon) return; + const updateBodyClasses = (theme) => { + if (theme === 'light') { + document.body.classList.add('light-theme', 'light-mode'); + } else { + document.body.classList.remove('light-theme', 'light-mode'); + } + }; + + // Initialize body classes on page load + updateBodyClasses(initial); + icon.textContent = initial === 'light' ? '🌙' : '☀️'; btn.addEventListener('click', function () { @@ -19,6 +30,7 @@ const next = current === 'dark' ? 'light' : 'dark'; document.documentElement.setAttribute('data-theme', next); + updateBodyClasses(next); localStorage.setItem('theme', next); icon.textContent = next === 'light' ? '🌙' : '☀️'; diff --git a/backend/alertsystem.py b/backend/alertsystem.py index bde3472..3dff6d2 100644 --- a/backend/alertsystem.py +++ b/backend/alertsystem.py @@ -683,19 +683,28 @@ def city_suggestions(): @app.route("/chatbot", methods=["POST"]) def chatbot(): + data = request.get_json(silent=True) or {} + + # Attempt to proxy request to the Advanced Chatbot Server (Port 5001) + try: + chatbot_url = os.environ.get("CHATBOT_API_URL", "http://127.0.0.1:5001/chatbot") + resp = requests.post(chatbot_url, json=data, timeout=5) + if resp.status_code == 200: + return jsonify(resp.json()), resp.status_code + print(f"Chatbot server returned status code {resp.status_code}. Falling back to in-process chatbot.") + except Exception as e: + print(f"Could not connect to Chatbot Server on port 5001 ({e}). Falling back to in-process chatbot.") + # Fallback to local in-process handler try: - data = request.get_json(silent=True) or {} payload, status = handle_chatbot_request(data) return jsonify(payload), status - - except Exception: - + except Exception as local_err: + print(f"Local chatbot error: {local_err}") return jsonify({ "success": False, - "message": - "Chatbot unavailable." - }) + "message": "Chatbot unavailable." + }), 500 # ========================================================= # LOCAL RUN diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..9da2535 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +Flask>=3.0.0 +Flask-CORS>=4.0.0 +requests>=2.31.0 +python-dotenv>=1.0.0 +gunicorn>=21.2.0