Spaces:
Runtime error
Runtime error
| 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 | |
| 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="/") |