Spaces:
Sleeping
Sleeping
kandi1clickkits
commited on
Commit
·
fb3a173
1
Parent(s):
a02591a
chart code with DB
Browse files
main.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
-
from fastapi import FastAPI, HTTPException
|
| 2 |
from fastapi.responses import HTMLResponse
|
|
|
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
app = FastAPI()
|
|
@@ -10,15 +11,9 @@ def create_gr_chart(categories, values):
|
|
| 10 |
return chart.launch()
|
| 11 |
|
| 12 |
@app.post("/form/")
|
| 13 |
-
async def show_chart(
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
# values.append(value)
|
| 17 |
-
|
| 18 |
-
# For simplicity, I'm assuming you have two lists of categories and values
|
| 19 |
-
# Modify this part based on your actual data structure
|
| 20 |
-
categories = ["Category1", "Category2", "Category3"]
|
| 21 |
-
values = [10, 20, 30]
|
| 22 |
|
| 23 |
return create_gr_chart(categories, values)
|
| 24 |
|
|
|
|
| 1 |
+
from fastapi import FastAPI, HTTPException
|
| 2 |
from fastapi.responses import HTMLResponse
|
| 3 |
+
from typing import List
|
| 4 |
import gradio as gr
|
| 5 |
|
| 6 |
app = FastAPI()
|
|
|
|
| 11 |
return chart.launch()
|
| 12 |
|
| 13 |
@app.post("/form/")
|
| 14 |
+
async def show_chart(data: List[dict]):
|
| 15 |
+
categories = [item["category"] for item in data]
|
| 16 |
+
values = [item["value"] for item in data]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
return create_gr_chart(categories, values)
|
| 19 |
|