Add multiple approaches for JSON serving
Browse files- Added HTML component with embedded JSON data
- Created iframe-based dashboard for manual JSON extraction
- JSON data embedded in hidden HTML element for external access
- Updates every 5 seconds automatically
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <[email protected]>
app.py
CHANGED
@@ -1179,6 +1179,32 @@ with gr.Blocks(css=custom_css, theme="soft", title="Trek Asistanı", head=storag
|
|
1179 |
# Auto-load on start
|
1180 |
demo.load(get_conversations_json, outputs=json_display)
|
1181 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1182 |
# API endpoints for dashboard
|
1183 |
def get_all_conversations():
|
1184 |
"""API endpoint to get all conversations"""
|
|
|
1179 |
# Auto-load on start
|
1180 |
demo.load(get_conversations_json, outputs=json_display)
|
1181 |
|
1182 |
+
# Add HTML component with embedded JSON for external access
|
1183 |
+
with gr.Row(visible=False):
|
1184 |
+
# Create an HTML element that contains the JSON data
|
1185 |
+
json_html = gr.HTML(
|
1186 |
+
value=lambda: create_json_html(),
|
1187 |
+
visible=False,
|
1188 |
+
elem_id="json_data_container"
|
1189 |
+
)
|
1190 |
+
|
1191 |
+
def create_json_html():
|
1192 |
+
"""Create HTML with embedded JSON data"""
|
1193 |
+
from conversation_tracker import load_conversations
|
1194 |
+
import json
|
1195 |
+
conversations = load_conversations()
|
1196 |
+
json_str = json.dumps(conversations, ensure_ascii=False)
|
1197 |
+
return f'''
|
1198 |
+
<div id="json-data" style="display:none;">
|
1199 |
+
<script type="application/json" id="conversations-json">
|
1200 |
+
{json_str}
|
1201 |
+
</script>
|
1202 |
+
</div>
|
1203 |
+
'''
|
1204 |
+
|
1205 |
+
# Update JSON HTML every 5 seconds
|
1206 |
+
demo.load(create_json_html, outputs=json_html, every=5)
|
1207 |
+
|
1208 |
# API endpoints for dashboard
|
1209 |
def get_all_conversations():
|
1210 |
"""API endpoint to get all conversations"""
|