Spaces:
Sleeping
Sleeping
Update api_gateway.py
Browse files- api_gateway.py +19 -0
api_gateway.py
CHANGED
|
@@ -1,12 +1,31 @@
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from pydantic import BaseModel
|
| 3 |
from codex_logic import assess_work_description, validate_use_case
|
|
|
|
| 4 |
|
| 5 |
app = FastAPI()
|
| 6 |
|
| 7 |
class EvaluationRequest(BaseModel):
|
| 8 |
work_description: str
|
| 9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
@app.post("/evaluate")
|
| 11 |
def evaluate_work(req: EvaluationRequest):
|
| 12 |
if not validate_use_case(req.work_description):
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from pydantic import BaseModel
|
| 3 |
from codex_logic import assess_work_description, validate_use_case
|
| 4 |
+
from fastapi.responses import HTMLResponse, RedirectResponse
|
| 5 |
|
| 6 |
app = FastAPI()
|
| 7 |
|
| 8 |
class EvaluationRequest(BaseModel):
|
| 9 |
work_description: str
|
| 10 |
|
| 11 |
+
@app.get("/", response_class=HTMLResponse)
|
| 12 |
+
def root():
|
| 13 |
+
return """
|
| 14 |
+
<html>
|
| 15 |
+
<head><title>CodexHF API Gateway</title></head>
|
| 16 |
+
<body style='font-family:monospace; background:#111; color:#0f0; text-align:center; padding:2em;'>
|
| 17 |
+
<h1>🧠 CodexHF Sovereign API Gateway</h1>
|
| 18 |
+
<p>✅ Status: <b>Running</b></p>
|
| 19 |
+
<p>Use <code>/evaluate</code> endpoint via POST</p>
|
| 20 |
+
<p><a href='/docs' style='color:#0f0;'>View API Documentation</a></p>
|
| 21 |
+
</body>
|
| 22 |
+
</html>
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
@app.get("/docs_redirect")
|
| 26 |
+
def docs_redirect():
|
| 27 |
+
return RedirectResponse(url="/docs")
|
| 28 |
+
|
| 29 |
@app.post("/evaluate")
|
| 30 |
def evaluate_work(req: EvaluationRequest):
|
| 31 |
if not validate_use_case(req.work_description):
|