chuckfinca Claude Opus 4.6 (1M context) commited on
Commit
78c1ba6
·
1 Parent(s): 93ce607

Embed shared CSS/JS inline instead of file serving

Browse files

Gradio file serving doesn't work reliably with Docker SDK.
Read chat-ui.css and chat-ui.js at startup and inject inline.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -220,6 +220,10 @@ def stream_question(
220
  # Gradio app
221
  # ---------------------------------------------------------------------------
222
 
 
 
 
 
223
  CUSTOM_HTML = """
224
  <div id="explorer-app">
225
  <div id="setup-panel">
@@ -249,8 +253,8 @@ CUSTOM_HTML = """
249
  </div>
250
  </div>
251
 
252
- <link rel="stylesheet" href="/file=static/chat-ui.css" />
253
- <script src="/file=static/chat-ui.js"></script>
254
  <style>
255
  #explorer-app { font-family: var(--font-family, 'Inter', system-ui, sans-serif); max-width: 800px; margin: 0 auto; }
256
  #setup-panel { padding: 24px 0; }
@@ -576,4 +580,4 @@ if __name__ == "__main__":
576
  print("WARNING: LH_ACCESS_TOKEN not set — app is unprotected")
577
 
578
  app = build_app()
579
- app.launch(server_name="0.0.0.0", server_port=7860, allowed_paths=["static"])
 
220
  # Gradio app
221
  # ---------------------------------------------------------------------------
222
 
223
+ _STATIC_DIR = Path(__file__).parent / "static"
224
+ _CHAT_UI_CSS = (_STATIC_DIR / "chat-ui.css").read_text() if (_STATIC_DIR / "chat-ui.css").exists() else ""
225
+ _CHAT_UI_JS = (_STATIC_DIR / "chat-ui.js").read_text() if (_STATIC_DIR / "chat-ui.js").exists() else ""
226
+
227
  CUSTOM_HTML = """
228
  <div id="explorer-app">
229
  <div id="setup-panel">
 
253
  </div>
254
  </div>
255
 
256
+ <style>""" + _CHAT_UI_CSS + """</style>
257
+ <script>""" + _CHAT_UI_JS + """</script>
258
  <style>
259
  #explorer-app { font-family: var(--font-family, 'Inter', system-ui, sans-serif); max-width: 800px; margin: 0 auto; }
260
  #setup-panel { padding: 24px 0; }
 
580
  print("WARNING: LH_ACCESS_TOKEN not set — app is unprotected")
581
 
582
  app = build_app()
583
+ app.launch(server_name="0.0.0.0", server_port=7860)