BF / static_files.py
SamiKoen's picture
Add JSON endpoint for dashboard CORS fix
09525e7
raw
history blame
543 Bytes
"""Serve static files with CORS headers"""
import gradio as gr
from pathlib import Path
import json
def serve_conversations():
"""Serve conversations.json with proper CORS headers"""
try:
with open('conversations.json', 'r') as f:
data = json.load(f)
return gr.JSON(data, headers={
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET",
"Access-Control-Allow-Headers": "Content-Type"
})
except:
return {"error": "File not found"}