Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
|
@@ -21,29 +21,20 @@ templates = Jinja2Templates(directory="templates")
|
|
| 21 |
async def show_form(request: Request):
|
| 22 |
return templates.TemplateResponse("form.html", {"request": request})
|
| 23 |
|
| 24 |
-
@app.post("/refine"
|
| 25 |
-
async def
|
| 26 |
result = run_refiner(idea)
|
| 27 |
|
| 28 |
-
# Format all results into Markdown
|
| 29 |
markdown_output = f"""
|
| 30 |
## 🧠 Refined Idea
|
| 31 |
{result['refined_idea']}
|
| 32 |
-
|
| 33 |
---
|
| 34 |
-
|
| 35 |
## 📊 Market Info
|
| 36 |
{result['market_info']}
|
| 37 |
-
|
| 38 |
---
|
| 39 |
-
|
| 40 |
## 📽️ Slide Summary
|
| 41 |
{result['slide_summary']}
|
| 42 |
"""
|
| 43 |
|
| 44 |
html_output = markdown(markdown_output)
|
| 45 |
-
|
| 46 |
-
return templates.TemplateResponse("result.html", {
|
| 47 |
-
"request": request,
|
| 48 |
-
"output_html": html_output
|
| 49 |
-
})
|
|
|
|
| 21 |
async def show_form(request: Request):
|
| 22 |
return templates.TemplateResponse("form.html", {"request": request})
|
| 23 |
|
| 24 |
+
@app.post("/api/refine")
|
| 25 |
+
async def refine_api(idea: str = Form(...)):
|
| 26 |
result = run_refiner(idea)
|
| 27 |
|
|
|
|
| 28 |
markdown_output = f"""
|
| 29 |
## 🧠 Refined Idea
|
| 30 |
{result['refined_idea']}
|
|
|
|
| 31 |
---
|
|
|
|
| 32 |
## 📊 Market Info
|
| 33 |
{result['market_info']}
|
|
|
|
| 34 |
---
|
|
|
|
| 35 |
## 📽️ Slide Summary
|
| 36 |
{result['slide_summary']}
|
| 37 |
"""
|
| 38 |
|
| 39 |
html_output = markdown(markdown_output)
|
| 40 |
+
return JSONResponse({"output_html": html_output})
|
|
|
|
|
|
|
|
|
|
|
|