diff --git a/optimade/server/routers/landing.py b/optimade/server/routers/landing.py index 3f4192329..c62eb2265 100644 --- a/optimade/server/routers/landing.py +++ b/optimade/server/routers/landing.py @@ -2,9 +2,8 @@ from pathlib import Path -from fastapi import Request +from fastapi import APIRouter, Request from fastapi.responses import HTMLResponse -from starlette.routing import Route, Router from optimade import __api_version__ from optimade.server.config import ServerConfig @@ -92,11 +91,11 @@ async def landing(request: Request): ) -router = Router(routes=[Route("/", endpoint=landing)]) - -## This "fix" is taken directly from FastAPI's APIRouter implementation. -# Handle on_startup/on_shutdown locally since Starlette removed support -# Ref: https://github.com/Kludex/starlette/pull/3117 -# TODO: deprecate this once the lifespan (or alternative) interface is improved -router.on_startup = [] -router.on_shutdown = [] +router = APIRouter(redirect_slashes=True) +router.add_api_route( + "/", + landing, + methods=["GET"], + response_class=HTMLResponse, + include_in_schema=False, +) diff --git a/pyproject.toml b/pyproject.toml index 609e8f1f9..c3cbb910f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,11 +75,7 @@ server = [ # Client minded aiida = ["aiida-core~=2.1"] -http-client = [ - "httpx~=0.23", - "rich>=13,<16", - "click~=8.1", -] +http-client = ["httpx~=0.23", "httpx2", "rich>=13,<16", "click~=8.1"] ase = ["ase~=3.22"] cif = ["numpy>=1.22,<3.0"]