Spaces:
Sleeping
Sleeping
| from fastapi import FastAPI, HTTPException | |
| from fastapi.responses import HTMLResponse | |
| import gradio as gr | |
| app = FastAPI() | |
| def create_chart(categories, values): | |
| data = {"students": categories, "marks": values} | |
| plot = gr.LinePlot(data, every=5, x="students", y="marks", y_title="marks (percent)", overlay_point=True, width=500, height=500) | |
| return plot | |
| async def show_chart(categories: list, values: list): | |
| chart = create_chart(categories, values) | |
| return HTMLResponse(content=chart.launch(), status_code=200) | |
| async def show_visualization(): | |
| # For simplicity, I'm assuming you have two lists of categories and values | |
| # Modify this part based on your actual data structure | |
| categories = ["Category1", "Category2", "Category3"] | |
| values = [10, 20, 30] | |
| chart = create_chart(categories, values) | |
| return HTMLResponse(content=chart.launch(), status_code=200) | |