Spaces:
Sleeping
Sleeping
File size: 971 Bytes
fb3a173 035d91e da0318e 8557221 ad90944 f3b2b4b da0318e 007a3ba 035d91e da0318e 035d91e a02591a da0318e | 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 | 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
@app.post("/form/")
async def show_chart(categories: list, values: list):
chart = create_chart(categories, values)
return HTMLResponse(content=chart.launch(), status_code=200)
@app.get("/visualization/", response_class=HTMLResponse)
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)
|