Added static files and favicon route

This commit is contained in:
2025-05-05 18:58:10 -05:00
parent ce34d2b712
commit 331687c3b3
3 changed files with 65 additions and 0 deletions

View File

@@ -1,7 +1,10 @@
import os
from fastapi.responses import RedirectResponse
import uvicorn import uvicorn
from fastapi import FastAPI from fastapi import FastAPI
from fastapi.security import HTTPBasic from fastapi.security import HTTPBasic
from routers import admin, content from routers import admin, content
from fastapi.staticfiles import StaticFiles
app = FastAPI() app = FastAPI()
security = HTTPBasic() security = HTTPBasic()
@@ -11,9 +14,16 @@ admin_security = HTTPBasic()
async def health_check(): async def health_check():
return {"status": "healthy"} return {"status": "healthy"}
@app.get("/favicon.ico")
async def get_favicon():
return RedirectResponse(url="/logo.png")
app.include_router(admin.router) app.include_router(admin.router)
app.include_router(content.router) app.include_router(content.router)
static_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "static")
app.mount("/", StaticFiles(directory=static_path, html=True), name="static")
if __name__ == "__main__": if __name__ == "__main__":
uvicorn.run( uvicorn.run(
"main:app", "main:app",

55
src/static/index.html Normal file
View File

@@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>IPTV Service</title>
<style>
body {
font-family: Arial, sans-serif;
line-height: 1.6;
max-width: 800px;
margin: 0 auto;
padding: 20px;
background-color: #f0f0f0;
}
.container {
background-color: white;
padding: 30px;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
h1 {
color: #2c3e50;
border-bottom: 2px solid #3498db;
padding-bottom: 10px;
}
.api-links {
margin-top: 20px;
}
a {
color: #3498db;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="container">
<h1>Welcome to the IPTV Service</h1>
<p>This service provides API endpoints for managing IPTV users and content.</p>
<div class="api-links">
<h2>API Documentation:</h2>
<ul>
<li><a href="/docs">Interactive Swagger UI</a></li>
<li><a href="/redoc">ReDoc Documentation</a></li>
</ul>
</div>
<p>For service administration, please use the authorized endpoints.</p>
</div>
</body>
</html>

BIN
src/static/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB