Spaces:
Sleeping
Sleeping
Kethan Dosapati
Remove Gradio-based UI implementation and replace it with a pure JavaScript-based static UI for articles, tips, and comments.
e87131b | """POST endpoint — submit a new article.""" | |
| from fastapi import APIRouter, HTTPException | |
| from database import supabase | |
| from models import ArticleIn, ArticleOut | |
| router = APIRouter(tags=["post"]) | |
| def create_article(article: ArticleIn): | |
| """Insert a new article into the knowledge base.""" | |
| payload = article.model_dump(exclude_none=True) | |
| result = ( | |
| supabase.table("articles") | |
| .insert(payload) | |
| .execute() | |
| ) | |
| if not result.data: | |
| raise HTTPException(status_code=500, detail="Failed to insert article") | |
| row = result.data[0] | |
| return ArticleOut(id=row["id"], title=row["title"], created_at=row["created_at"]) | |