Spaces:
Sleeping
Sleeping
Kethan Dosapati
Add static UI implementation for browsing, submitting, and searching tips with HTML, CSS, and JavaScript; remove dependency on Gradio-based UI.
8893529 | """ | |
| Yantrabodha Article API | |
| ======================= | |
| FastAPI app backed by Supabase (Postgres). Endpoints: | |
| - GET / β static UI (browse, submit, search tips) | |
| - GET /api/articles β list recent articles | |
| - POST /api/post, POST /post β submit article (same; /post for PyPI client) | |
| - POST /api/report, POST /report β report (MCP structured payload) | |
| - GET /api/match, GET /match β full-text search (/match for PyPI client) | |
| Environment variables: | |
| SUPABASE_URL β from Supabase Project Settings β API | |
| SUPABASE_SERVICE_KEY β service role key (bypasses RLS) | |
| """ | |
| from pathlib import Path | |
| from fastapi import FastAPI | |
| from fastapi.staticfiles import StaticFiles | |
| from database import supabase # noqa: F401 β ensure DB is loaded | |
| from endpoints.articles import router as articles_router | |
| from endpoints.comments import router as comments_router | |
| from endpoints.config import router as config_router | |
| from endpoints.match import router as match_router | |
| from endpoints.post import router as post_router | |
| from endpoints.report import router as report_router | |
| app = FastAPI(title="Yantrabodha API", version="1.0.0") | |
| app.include_router(post_router, prefix="/api/post") | |
| app.include_router(match_router, prefix="/api/match") | |
| app.include_router(report_router, prefix="/api") | |
| app.include_router(config_router, prefix="/api") | |
| # More specific routes first: /api/articles/{id}/comments before /api/articles | |
| app.include_router(comments_router, prefix="/api") | |
| app.include_router(articles_router, prefix="/api") | |
| # Backward compatibility: PyPI client (yantrabodha_mcp) uses /post and /match without /api | |
| app.include_router(post_router, prefix="/post") | |
| app.include_router(match_router, prefix="/match") | |
| # MCP may call either /report or /api/report | |
| app.include_router(report_router, prefix="") | |
| # Static UI last so /api/* and /post, /match take precedence | |
| static_dir = Path(__file__).parent / "static" | |
| app.mount("/", StaticFiles(directory=str(static_dir), html=True), name="static") | |