Skip to content

Commit 8348606

Browse files
authored
Merge pull request #10 from tisnik/root-endpoint-handler
Root endpoint handler
2 parents ddace9e + f8f89e1 commit 8348606

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/app/endpoints/root.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
"""Handler for the / endpoint."""
2+
3+
import asyncio
4+
import logging
5+
from typing import Any, Optional
6+
7+
from fastapi import APIRouter, Request
8+
from fastapi.responses import HTMLResponse
9+
10+
logger = logging.getLogger(__name__)
11+
router = APIRouter(tags=["root"])
12+
13+
14+
@router.get("/", response_class=HTMLResponse)
15+
def root_endpoint_handler(request: Request) -> HTMLResponse:
16+
return "<html>foo</html>"

src/app/routers.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
from fastapi import FastAPI
44

5-
from app.endpoints import info, models
5+
from app.endpoints import info, models, root
66

77

88
def include_routers(app: FastAPI) -> None:
@@ -11,5 +11,6 @@ def include_routers(app: FastAPI) -> None:
1111
Args:
1212
app: The `FastAPI` app instance.
1313
"""
14+
app.include_router(root.router)
1415
app.include_router(info.router, prefix="/v1")
1516
app.include_router(models.router, prefix="/v1")

0 commit comments

Comments
 (0)