Skip to content

Fix dead code in toggle_theme() by implementing theme cookie toggle#514

Open
mohityadav8 wants to merge 4 commits into
adeyosemanputra:v3.0.0-prefrom
mohityadav8:patch-1
Open

Fix dead code in toggle_theme() by implementing theme cookie toggle#514
mohityadav8 wants to merge 4 commits into
adeyosemanputra:v3.0.0-prefrom
mohityadav8:patch-1

Conversation

@mohityadav8

Copy link
Copy Markdown
Contributor

Fixes BUG in dockerized_labs/template_injection_lab/app.py.

The toggle_theme() function previously returned a 204 response without performing any action, making the theme toggle feature non-functional.

This update:

  • Reads the current theme from cookies
  • Toggles between light and dark theme
  • Sets the updated theme using response.set_cookie()

This removes the dead code and restores expected theme toggle functionality.

Fixes BUG in dockerized_labs/template_injection_lab/app.py.

The toggle_theme() function previously returned a 204 response without performing any action, making the theme toggle feature non-functional.

This update:
- Reads the current theme from cookies
- Toggles between light and dark theme
- Sets the updated theme using response.set_cookie()

This removes the dead code and restores expected theme toggle functionality.
Refactor theme toggle functionality and remove duplicate imports.
Comment thread dockerized_labs/template_injection_lab/app.py
Comment thread dockerized_labs/template_injection_lab/app.py
@mohityadav8

Copy link
Copy Markdown
Contributor Author

@RupakBiswas-2304 @Garvita-k My bad — I accidentally removed the index() function while restructuring the routes. I've added it back now, both @app.route("/") with def index() and @app.route("/toggle-theme") with def toggle_theme() are intact and separate. Could you please re-review and merge when you get a chance? Thanks!

@mohityadav8 mohityadav8 requested a review from Garvita-k April 25, 2026 17:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants