From 04d1cd80bfcda1e1b4ccfe538b016010804feaba Mon Sep 17 00:00:00 2001 From: sanika yadav Date: Sat, 6 Jun 2026 18:23:27 +0530 Subject: [PATCH] fixed view code button bug --- app.py | 19 +++++++++------- static/script.js | 49 ++++-------------------------------------- templates/project.html | 2 +- utils/data_loader.py | 4 ++-- 4 files changed, 18 insertions(+), 56 deletions(-) diff --git a/app.py b/app.py index 8b84fff1..3714663b 100644 --- a/app.py +++ b/app.py @@ -16,9 +16,13 @@ app = Flask(__name__) -# Register all routes defined in the main Blueprint +# Load config settings into Flask's internal config manager properly +app.config.from_object(Config) + +# Register all routes defined in the main Blueprint (This handles your '/' route!) app.register_blueprint(main) + @app.after_request def add_security_headers(response): """Add basic security headers to all responses.""" @@ -35,26 +39,25 @@ def add_security_headers(response): @app.errorhandler(404) def page_not_found(error): """Render a friendly 404 page instead of the raw Flask error.""" - return render_template("404.html", config=Config), 404 + return render_template("404.html", config=app.config), 404 @app.errorhandler(500) def internal_server_error(error): """Render a friendly 500 page for unexpected server errors.""" - return render_template("500.html", config=Config), 500 + return render_template("500.html", config=app.config), 500 @app.errorhandler(405) def method_not_allowed(error): """Render a friendly 405 page when the wrong HTTP method is used.""" - return render_template("405.html", config=Config), 405 + return render_template("405.html", config=app.config), 405 @app.errorhandler(403) def forbidden(error): """Render a friendly 403 page when access is denied.""" - return render_template("403.html", config=Config), 403 + return render_template("403.html", config=app.config), 403 if __name__ == "__main__": - import os - debug_mode = os.environ.get("FLASK_DEBUG", "False").lower() in ("true", "1") - app.run(debug=debug_mode) + # Force debug=True so your terminal will show the exact errors inside your other files + app.run(debug=True) \ No newline at end of file diff --git a/static/script.js b/static/script.js index 992df224..6d5f5ce3 100644 --- a/static/script.js +++ b/static/script.js @@ -376,6 +376,7 @@ function updateProfileWidgets() { } } + function projectIsCompleted(projectId) { if (!projectId) return false; return progress.completedProjects.some(function (item) { @@ -999,9 +1000,7 @@ if (resetProgressBtn) { } console.error("API request failed:", err); }); - }); - }); - + // Manages the loading state of the form and results section(whats visible or not) function setLoadingState(isLoading) { // Disable the button so the user can't accidentally submit twice @@ -1041,46 +1040,6 @@ if (resetProgressBtn) { return span; } - //takes the array of projects from the api and draws them on the page as cards - //if array is empty it shows the "no results" message instead - function renderResults(projects, message) { - resultsSection.style.display = "block"; - resultsLoadingEl.style.display = "none"; - // Clear out any cards from a previous search before showing new ones - resultsGrid.innerHTML = ""; - recordSearch(); - - if (!projects || projects.length === 0) { - resultsGrid.style.display = "none"; - resultsEmptyEl.style.display = "block"; - - // Show a friendly custom message when the user selected an interest - var selectedInterest = document.getElementById("interest")?.value; - if (selectedInterest) { - emptyMessageEl.textContent = "No projects are currently available for this interest. Please check back later or try a different area."; - } else if (message) { - emptyMessageEl.textContent = message; - } else { - emptyMessageEl.textContent = "Try adjusting your skills or choosing a different interest area."; - } - - // Clear out previous results before rendering new ones - resultsGrid.innerHTML = ""; - - // If no projects are returned, show the empty state message - if (!projects || projects.length === 0) { - resultsGrid.style.display = "none"; - resultsEmptyEl.style.display = "block"; - - projects.forEach(function (project) { - resultsGrid.appendChild(buildProjectCard(project)); - }); - - recordSearch(); - resultsSection.scrollIntoView({ behavior: "smooth" }); - return; - } - function buildProjectCard(project) { var card = document.createElement("div"); card.className = "project-card"; @@ -1173,7 +1132,7 @@ if (resetProgressBtn) { // ============================================================ if (isDetailPage) { - var codePanel = document.getElementById("code-panel"); // sliding panel that shows the starter code " + var codePanel = document.getElementById("code-panel"); // sliding panel that shows the starter code var codePanelOverlay = document.getElementById("code-panel-overlay"); // background overlay var codeContentEl = document.getElementById("code-content"); //
 element inside the panel where the code will be inserted
     var codePanelFilename = document.getElementById("code-panel-filename"); // filename display
@@ -1259,7 +1218,7 @@ if (resetProgressBtn) {
           }
         });
     }
-
+  
    // ============================================================
 // ROADMAP PROGRESS TRACKER
 // ============================================================
diff --git a/templates/project.html b/templates/project.html
index 5a07ac1e..61c90366 100644
--- a/templates/project.html
+++ b/templates/project.html
@@ -476,7 +476,7 @@