warm reloading
change
commit 0b5bdf6dbaf1ef2c5c28a4f8844aaa0be8b9e011
author Alpha Chen <alpha@kejadlen.dev>
date
parent 0ea38116
diff --git a/go_ji/__init__.py b/go_ji/__init__.py
index 2b82c1a..3abb248 100644
--- a/go_ji/__init__.py
+++ b/go_ji/__init__.py
@@ -61,8 +61,8 @@ def create_app(config_override: dict[str, Any] = {}) -> Flask:
 
     @app.before_request
     def require_user() -> None:
-        # Allow anonymous requests for the healthcheck and hot-reloading
-        if request.path in ["/up", "hot-reload"]:
+        # Allow anonymous requests for the healthcheck and warm-reloading
+        if request.path in ["/up", "warm-reload"]:
             return
 
         # I think this is unnecessary, but it also doesn't hurt
@@ -107,9 +107,8 @@ def create_app(config_override: dict[str, Any] = {}) -> Flask:
         ).all()
         return render_template(
             "index.html",
-            name=g.user.login,
             top_shorts=top_shorts,
-            hot_reload=bool(sock),
+            warm_reload=bool(sock),
         )
 
     @app.route("/links", methods=["POST"])
@@ -157,12 +156,12 @@ def create_app(config_override: dict[str, Any] = {}) -> Flask:
         1 / 0  # raises an error
         return "<p>Hello, World!</p>"  # pragma: no cover
 
-    # hot-reloading - hold the websocket open forever in debug mode and when it
+    # warm-reloading - hold the websocket open forever in debug mode and when it
     # disconnects, then we know we need to reload
     if sock:  # pragma: no cover
 
-        @sock.route("/hot-reload")
-        def hot_reload(ws: WsServer) -> None:
+        @sock.route("/warm-reload")
+        def warm_reload(ws: WsServer) -> None:
             while True:
                 pass
 
diff --git a/go_ji/templates/index.html b/go_ji/templates/index.html
index 736b7ce..3e5ff97 100644
--- a/go_ji/templates/index.html
+++ b/go_ji/templates/index.html
@@ -23,8 +23,8 @@
       </tr>
       {% endfor %}
     </table>
-    {% if hot_reload %}
-      {% include "hot_reload.html" %}
+    {% if warm_reload %}
+      {% include "warm_reload.html" %}
     {% endif %}
   </body>
 </html>
diff --git a/go_ji/templates/hot_reload.html b/go_ji/templates/warm_reload.html
similarity index 66%
rename from go_ji/templates/hot_reload.html
rename to go_ji/templates/warm_reload.html
index 47a9cf6..9cb3dfe 100644
--- a/go_ji/templates/hot_reload.html
+++ b/go_ji/templates/warm_reload.html
@@ -1,5 +1,5 @@
 <script>
-  const socket = new WebSocket('ws://' + location.host + '/hot-reload');
+  const socket = new WebSocket('ws://' + location.host + '/warm-reload');
   const cb = ev => {
     setTimeout(() => { window.location.reload(); }, 500);
   };