@@ -82,6 +82,11 @@ async def allow_cors_on_endpoint(request: web.Request):
8282 )
8383
8484
85+ async def http_not_found (request : web .Request ):
86+ """Return a 404 error for unknown URLs."""
87+ return web .HTTPNotFound ()
88+
89+
8590app = web .Application (middlewares = [server_version_middleware ])
8691cors = aiohttp_cors .setup (app )
8792
@@ -110,9 +115,9 @@ async def allow_cors_on_endpoint(request: web.Request):
110115 web .get ("/status/check/ipv6" , status_check_ipv6 ),
111116 web .get ("/status/config" , status_public_config ),
112117 # Raise an HTTP Error 404 if attempting to access an unknown URL within these paths.
113- web .get ("/about/{suffix:.*}" , lambda _ : web . HTTPNotFound () ),
114- web .get ("/control/{suffix:.*}" , lambda _ : web . HTTPNotFound () ),
115- web .get ("/status/{suffix:.*}" , lambda _ : web . HTTPNotFound () ),
118+ web .get ("/about/{suffix:.*}" , http_not_found ),
119+ web .get ("/control/{suffix:.*}" , http_not_found ),
120+ web .get ("/status/{suffix:.*}" , http_not_found ),
116121 # /static is used to serve static files
117122 web .static ("/static" , Path (__file__ ).parent / "views/static" ),
118123 # /vm is used to launch VMs on-demand
0 commit comments