Skip to content

Commit c2b3b56

Browse files
committed
(api) Add nice index page
Signed-off-by: Denys Fedoryshchenko <denys.f@collabora.com>
1 parent 9fee2d0 commit c2b3b56

2 files changed

Lines changed: 33 additions & 2 deletions

File tree

api/main.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
Body,
2929
)
3030
from fastapi.encoders import jsonable_encoder
31-
from fastapi.responses import JSONResponse, PlainTextResponse, FileResponse
31+
from fastapi.responses import JSONResponse, PlainTextResponse, FileResponse, HTMLResponse
3232
from fastapi.security import OAuth2PasswordRequestForm
3333
from fastapi_pagination import add_pagination
3434
from fastapi_versioning import VersionedFastAPI
@@ -132,7 +132,10 @@ async def invalid_id_exception_handler(
132132
async def root():
133133
"""Root endpoint handler"""
134134
metrics.add('http_requests_total', 1)
135-
return {"message": "KernelCI API"}
135+
root_dir = os.path.dirname(os.path.abspath(__file__))
136+
index_path = os.path.join(root_dir, 'templates', 'index.html')
137+
with open(index_path, 'r', encoding='utf-8') as file:
138+
return HTMLResponse(file.read())
136139

137140
# -----------------------------------------------------------------------------
138141
# Users

api/templates/index.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
6+
<title>KernelCI API Server</title>
7+
<style>
8+
body { font-family: Arial, sans-serif; background: #f8f9fa; color: #222; margin: 0; padding: 0; }
9+
.container { max-width: 600px; margin: 60px auto; background: #fff; border-radius: 10px; box-shadow: 0 2px 8px rgba(0,0,0,0.07); padding: 32px; }
10+
h1 { color: #0057b7; }
11+
a { color: #0057b7; text-decoration: none; }
12+
a:hover { text-decoration: underline; }
13+
.logo { width: 120px; margin-bottom: 24px; }
14+
</style>
15+
</head>
16+
<body>
17+
<div class="container">
18+
<img src="https://kernelci.org/wp-content/uploads/sites/92/2019/10/kernelci-horizontal-color.svg" alt="KernelCI Logo" class="logo"/>
19+
<h1>KernelCI API Server</h1>
20+
<p>Welcome! This is the <b>KernelCI API</b> server endpoint.</p>
21+
<p>Use this service to interact with the KernelCI Maestro API via RESTful API calls.</p>
22+
<p>For more information about KernelCI, please visit <a href="https://kernelci.org/" target="_blank">kernelci.org</a>.</p>
23+
<p>API documentation and usage instructions can be found in the <a href="https://docs.kernelci.org/" target="_blank">KernelCI documentation</a>.</p>
24+
<hr/>
25+
<p style="font-size: 0.95em; color: #888;">&copy; 2025 KernelCI Project</p>
26+
</div>
27+
</body>
28+
</html>

0 commit comments

Comments
 (0)