From 4154bd053ebb926e0ea3f9e231e38228dc456727 Mon Sep 17 00:00:00 2001 From: CHARU AWASTHI <148922861+Charu19awasthi@users.noreply.github.com> Date: Sat, 11 Jan 2025 18:48:18 +0530 Subject: [PATCH 1/5] Create FLASK BACKEND,py --- FLASK BACKEND,py | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 FLASK BACKEND,py diff --git a/FLASK BACKEND,py b/FLASK BACKEND,py new file mode 100644 index 0000000..4eb9d87 --- /dev/null +++ b/FLASK BACKEND,py @@ -0,0 +1,63 @@ +from flask import Flask, render_template, session, redirect, url_for, request +import mysql.connector + +app = Flask(__name__) +app.secret_key = 'supersecretkey' + +# Connect to MySQL database +def get_db_connection(): + return mysql.connector.connect( + host="localhost", + user="root", + password="yourpassword", + database="finance_data" + ) + +@app.route('/dashboard') +def dashboard(): + if 'user_id' not in session: + return redirect(url_for('login')) + + user_id = session['user_id'] + + connection = get_db_connection() + cursor = connection.cursor(dictionary=True) + + # Fetch user's visualizations + cursor.execute("SELECT * FROM visualizations WHERE user_id = %s", (user_id,)) + visualizations = cursor.fetchall() + + # Fetch user's uploaded data + cursor.execute("SELECT * FROM uploaded_data WHERE user_id = %s", (user_id,)) + uploaded_data = cursor.fetchall() + + cursor.close() + connection.close() + + return render_template('dashboard.html', visualizations=visualizations, uploaded_data=uploaded_data) + +@app.route('/login', methods=['GET', 'POST']) +def login(): + if request.method == 'POST': + username = request.form['username'] + password = request.form['password'] + + # Check credentials (add hash check for security) + connection = get_db_connection() + cursor = connection.cursor(dictionary=True) + cursor.execute("SELECT * FROM user WHERE username = %s AND password = %s", (username, password)) + user = cursor.fetchone() + + cursor.close() + connection.close() + + if user: + session['user_id'] = user['user_id'] + return redirect(url_for('dashboard')) + + return "Invalid credentials", 401 + + return render_template('login.html') + +if __name__ == "__main__": + app.run(debug=True) From 401677fbd76f7dafeb0fbbc3b1929561a6fb7ef3 Mon Sep 17 00:00:00 2001 From: CHARU AWASTHI <148922861+Charu19awasthi@users.noreply.github.com> Date: Sat, 11 Jan 2025 18:49:15 +0530 Subject: [PATCH 2/5] Create dashboard.html --- dashboard.html | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 dashboard.html diff --git a/dashboard.html b/dashboard.html new file mode 100644 index 0000000..bee6ea1 --- /dev/null +++ b/dashboard.html @@ -0,0 +1,32 @@ + + + + + + User Dashboard + + +

Welcome to Your Dashboard

+
+

Your Visualizations

+ +
+
+

Your Uploaded Data

+ +
+ + + + + + + From f0a0289152559bf3801cfd7301cfad7947a10e31 Mon Sep 17 00:00:00 2001 From: CHARU AWASTHI <148922861+Charu19awasthi@users.noreply.github.com> Date: Sat, 11 Jan 2025 18:50:13 +0530 Subject: [PATCH 3/5] Create styles.css --- styles.css | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 styles.css diff --git a/styles.css b/styles.css new file mode 100644 index 0000000..3bff901 --- /dev/null +++ b/styles.css @@ -0,0 +1,20 @@ +/* Light Theme (default) */ +body { + background-color: #fff; + color: #000; +} + +/* Dark Theme */ +body.dark-theme { + background-color: #333; + color: #fff; +} + +button { + padding: 10px 20px; + cursor: pointer; + background-color: #007BFF; + color: white; + border: none; + border-radius: 5px; +} From 9b4d53b8d9f0a5ae86d84f12bd25babc28d11edd Mon Sep 17 00:00:00 2001 From: CHARU AWASTHI <148922861+Charu19awasthi@users.noreply.github.com> Date: Sat, 11 Jan 2025 18:52:24 +0530 Subject: [PATCH 4/5] Create theme.js --- theme.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 theme.js diff --git a/theme.js b/theme.js new file mode 100644 index 0000000..cbad703 --- /dev/null +++ b/theme.js @@ -0,0 +1,18 @@ +// Function to toggle between light and dark modes +function toggleTheme() { + var body = document.body; + body.classList.toggle('dark-theme'); + // Store theme in localStorage so it's persistent + if (body.classList.contains('dark-theme')) { + localStorage.setItem('theme', 'dark'); + } else { + localStorage.setItem('theme', 'light'); + } +} + +// On page load, apply the saved theme +window.onload = function() { + if (localStorage.getItem('theme') === 'dark') { + document.body.classList.add('dark-theme'); + } +} From af1f684831c044367ab76248db7ef3b6f659fc7f Mon Sep 17 00:00:00 2001 From: CHARU AWASTHI <148922861+Charu19awasthi@users.noreply.github.com> Date: Fri, 17 Jan 2025 23:15:45 +0530 Subject: [PATCH 5/5] Rename FLASK BACKEND,py to flask_backend.py --- FLASK BACKEND,py => flask_backend.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename FLASK BACKEND,py => flask_backend.py (100%) diff --git a/FLASK BACKEND,py b/flask_backend.py similarity index 100% rename from FLASK BACKEND,py rename to flask_backend.py