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

Enable hot reload for development server #36

Merged
merged 1 commit into from
May 31, 2024

Conversation

K-dash
Copy link
Collaborator

@K-dash K-dash commented May 31, 2024

It was inconvenient because file updates were not automatically reflected when Flask was running.
Therefore, we enabled hot reloading of Flask.

  • Updated server.py to pass the debug parameter to app.run() based on the DEBUG environment variable.
  • Added a new DEBUG field to the ServerSettings class in settings.py with a default value of True.

By setting debug=True, The server automatically restarts whenever a file is modified.

@@ -4,7 +4,7 @@ repos:
hooks:
# Run the linter.
- id: ruff
args: [ ., --fix, --diff ]
entry: ruff check . --fix
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the --diff option because it was difficult to understand the content of the ruff error without displaying it!

@ryansurf
Copy link
Owner

Genius. I kept running the server, seeing an error, stopping the server, changing a file and then starting the server again to see if the bug was fixed. That was getting... tedious 😂

Good call, merging

@ryansurf ryansurf closed this May 31, 2024
@ryansurf ryansurf reopened this May 31, 2024
@ryansurf ryansurf merged commit 5265486 into ryansurf:main May 31, 2024
4 checks passed
@K-dash
Copy link
Collaborator Author

K-dash commented May 31, 2024

@ryansurf
Thanks!
Another benefit of setting the debug mode to True is that when an error occurs, Flask will display the error's stack trace on the screen 🥴
image

@K-dash K-dash deleted the feature/enable-hot-reload branch May 31, 2024 22:44
@ryansurf
Copy link
Owner

ryansurf commented Jun 1, 2024

Woah, that is useful. Nice!

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.

2 participants