Spaces:
Runtime error
Runtime error
File size: 591 Bytes
56d4821 f7d012e 56d4821 f7d012e 56d4821 f7d012e 56d4821 f7d012e 56d4821 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 | import gradio as gr
from fastapi import FastAPI
from fastapi.responses import JSONResponse
import json
# Create FastAPI app
app = FastAPI()
# Load JSON file
with open("materials_data.json", "r", encoding="utf-8") as file:
materials_data = json.load(file)
# API Endpoint
@app.get("/materials")
def get_materials():
return JSONResponse(content=materials_data)
# Simple Gradio UI
demo = gr.Interface(
fn=lambda: "Study Materials API Running",
inputs=[],
outputs="text",
title="Study Materials API"
)
# Mount Gradio app
app = gr.mount_gradio_app(app, demo, path="/") |