andito HF Staff commited on
Commit
8e7f67a
·
verified ·
1 Parent(s): 1034fb6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -10
app.py CHANGED
@@ -1765,9 +1765,11 @@ APP_JS = """
1765
  let pendingControlActions = [];
1766
 
1767
  const getAuthToken = () => {
1768
- const token = window.KEYBOARD_TOKEN || '';
 
 
1769
  if (token) {
1770
- console.log('[Control] Got keyboard token:', token.substring(0, 15) + '...');
1771
  } else {
1772
  console.log('[Control] No keyboard token available');
1773
  }
@@ -2052,14 +2054,11 @@ with gr.Blocks(
2052
  </div>
2053
  """
2054
 
2055
- # Inject token directly into keyboard HTML
2056
  token = oauth_token.token
2057
- return KEYBOARD_VIZ_HTML_INLINE + f"""
2058
- <script>
2059
- // Store token for keyboard controls
2060
- window.KEYBOARD_TOKEN = '{token}';
2061
- console.log('[Keyboard] Token injected, length:', '{token}'.length);
2062
- </script>
2063
  """
2064
 
2065
  keyboard_html = gr.HTML()
@@ -2151,4 +2150,3 @@ if __name__ == "__main__":
2151
  print("🚀 Server starting on http://0.0.0.0:7860")
2152
  print("ℹ️ Point your Robot/Sim to: ws://<YOUR_PC_IP>:7860/robot")
2153
  uvicorn.run(app, host="0.0.0.0", port=7860, proxy_headers=True, forwarded_allow_ips="*", log_level="warning")
2154
-
 
1765
  let pendingControlActions = [];
1766
 
1767
  const getAuthToken = () => {
1768
+ // Try to get token from data attribute first
1769
+ const container = document.getElementById('keyboard-token-container');
1770
+ const token = container ? container.getAttribute('data-token') : '';
1771
  if (token) {
1772
+ console.log('[Control] Got keyboard token from data attribute:', token.substring(0, 15) + '...');
1773
  } else {
1774
  console.log('[Control] No keyboard token available');
1775
  }
 
2054
  </div>
2055
  """
2056
 
2057
+ # Inject token directly into keyboard HTML via data attribute
2058
  token = oauth_token.token
2059
+ return f"""
2060
+ <div id="keyboard-token-container" data-token="{token}" style="display:none;"></div>
2061
+ {KEYBOARD_VIZ_HTML_INLINE}
 
 
 
2062
  """
2063
 
2064
  keyboard_html = gr.HTML()
 
2150
  print("🚀 Server starting on http://0.0.0.0:7860")
2151
  print("ℹ️ Point your Robot/Sim to: ws://<YOUR_PC_IP>:7860/robot")
2152
  uvicorn.run(app, host="0.0.0.0", port=7860, proxy_headers=True, forwarded_allow_ips="*", log_level="warning")