Spaces:
Sleeping
Sleeping
Commit ·
bc00e0f
1
Parent(s): 9b644f9
Add beautiful English main page with JANGG AI API branding and endpoint documentation
Browse files- app/main.py +75 -4
app/main.py
CHANGED
|
@@ -1,9 +1,10 @@
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from fastapi.staticfiles import StaticFiles
|
|
|
|
| 3 |
|
| 4 |
from app.routers import chat, quiz, audio
|
| 5 |
|
| 6 |
-
app = FastAPI(title="
|
| 7 |
|
| 8 |
app.mount("/static", StaticFiles(directory="app/static"), name="static")
|
| 9 |
|
|
@@ -11,10 +12,80 @@ app.include_router(chat.router)
|
|
| 11 |
app.include_router(quiz.router)
|
| 12 |
app.include_router(audio.router)
|
| 13 |
|
| 14 |
-
@app.get("/")
|
| 15 |
async def root():
|
| 16 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
@app.get("/health")
|
| 19 |
async def health_check():
|
| 20 |
-
return {"status": "healthy"}
|
|
|
|
| 1 |
from fastapi import FastAPI
|
| 2 |
from fastapi.staticfiles import StaticFiles
|
| 3 |
+
from fastapi.responses import HTMLResponse
|
| 4 |
|
| 5 |
from app.routers import chat, quiz, audio
|
| 6 |
|
| 7 |
+
app = FastAPI(title="JANGG AI API", description="Intelligent API for interactive learning with AI")
|
| 8 |
|
| 9 |
app.mount("/static", StaticFiles(directory="app/static"), name="static")
|
| 10 |
|
|
|
|
| 12 |
app.include_router(quiz.router)
|
| 13 |
app.include_router(audio.router)
|
| 14 |
|
| 15 |
+
@app.get("/", response_class=HTMLResponse)
|
| 16 |
async def root():
|
| 17 |
+
html_content = """
|
| 18 |
+
<!DOCTYPE html>
|
| 19 |
+
<html>
|
| 20 |
+
<head>
|
| 21 |
+
<title>JANGG AI API</title>
|
| 22 |
+
<style>
|
| 23 |
+
body { font-family: Arial, sans-serif; max-width: 800px; margin: 0 auto; padding: 20px; }
|
| 24 |
+
.header { text-align: center; color: #2c3e50; margin-bottom: 30px; }
|
| 25 |
+
.endpoint { background: #f8f9fa; padding: 15px; margin: 10px 0; border-radius: 5px; border-left: 4px solid #3498db; }
|
| 26 |
+
.method { color: #27ae60; font-weight: bold; }
|
| 27 |
+
.path { color: #2980b9; font-family: monospace; }
|
| 28 |
+
.description { color: #34495e; margin-top: 5px; }
|
| 29 |
+
.docs-link { background: #3498db; color: white; padding: 10px 20px; text-decoration: none; border-radius: 5px; display: inline-block; margin-top: 20px; }
|
| 30 |
+
</style>
|
| 31 |
+
</head>
|
| 32 |
+
<body>
|
| 33 |
+
<div class="header">
|
| 34 |
+
<h1>🤖 JANGG AI API</h1>
|
| 35 |
+
<p>Intelligent API for interactive learning with AI</p>
|
| 36 |
+
</div>
|
| 37 |
+
|
| 38 |
+
<h2>📚 Available Endpoints</h2>
|
| 39 |
+
|
| 40 |
+
<div class="endpoint">
|
| 41 |
+
<span class="method">GET</span> <span class="path">/</span>
|
| 42 |
+
<div class="description">API home page</div>
|
| 43 |
+
</div>
|
| 44 |
+
|
| 45 |
+
<div class="endpoint">
|
| 46 |
+
<span class="method">GET</span> <span class="path">/health</span>
|
| 47 |
+
<div class="description">API health check</div>
|
| 48 |
+
</div>
|
| 49 |
+
|
| 50 |
+
<div class="endpoint">
|
| 51 |
+
<span class="method">POST</span> <span class="path">/chat/</span>
|
| 52 |
+
<div class="description">AI chat interface for interactive conversations</div>
|
| 53 |
+
</div>
|
| 54 |
+
|
| 55 |
+
<div class="endpoint">
|
| 56 |
+
<span class="method">POST</span> <span class="path">/quiz/generate</span>
|
| 57 |
+
<div class="description">Generate personalized quizzes based on a topic</div>
|
| 58 |
+
</div>
|
| 59 |
+
|
| 60 |
+
<div class="endpoint">
|
| 61 |
+
<span class="method">POST</span> <span class="path">/quiz/validate</span>
|
| 62 |
+
<div class="description">Validate quiz answers</div>
|
| 63 |
+
</div>
|
| 64 |
+
|
| 65 |
+
<div class="endpoint">
|
| 66 |
+
<span class="method">POST</span> <span class="path">/audio/text-to-speech</span>
|
| 67 |
+
<div class="description">Convert text to speech</div>
|
| 68 |
+
</div>
|
| 69 |
+
|
| 70 |
+
<div class="endpoint">
|
| 71 |
+
<span class="method">POST</span> <span class="path">/audio/speech-to-text</span>
|
| 72 |
+
<div class="description">Convert speech to text</div>
|
| 73 |
+
</div>
|
| 74 |
+
|
| 75 |
+
<div style="text-align: center; margin-top: 30px;">
|
| 76 |
+
<a href="/docs" class="docs-link">📖 Interactive Documentation (Swagger)</a>
|
| 77 |
+
<br><br>
|
| 78 |
+
<a href="/redoc" class="docs-link">📋 Alternative Documentation (ReDoc)</a>
|
| 79 |
+
</div>
|
| 80 |
+
|
| 81 |
+
<div style="text-align: center; margin-top: 30px; color: #7f8c8d;">
|
| 82 |
+
<p>© 2026 JANGG AI API - Intelligent Learning Platform</p>
|
| 83 |
+
</div>
|
| 84 |
+
</body>
|
| 85 |
+
</html>
|
| 86 |
+
"""
|
| 87 |
+
return HTMLResponse(content=html_content)
|
| 88 |
|
| 89 |
@app.get("/health")
|
| 90 |
async def health_check():
|
| 91 |
+
return {"status": "healthy", "api": "JANGG AI API", "version": "1.0.0"}
|