shashidharak99's picture
Update app.py
56d4821 verified
raw
history blame contribute delete
591 Bytes
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="/")