generated from hjess/PythonTemplateProject
This commit is contained in:
10
app/main.py
10
app/main.py
@@ -17,6 +17,7 @@ class Application:
|
|||||||
self.app = FastAPI( lifespan = self._lifespan_event )
|
self.app = FastAPI( lifespan = self._lifespan_event )
|
||||||
self._set_image_sizes()
|
self._set_image_sizes()
|
||||||
self._setup_static_files()
|
self._setup_static_files()
|
||||||
|
self._setup_health_route()
|
||||||
self._include_routers()
|
self._include_routers()
|
||||||
self._include_middelware()
|
self._include_middelware()
|
||||||
|
|
||||||
@@ -53,6 +54,11 @@ class Application:
|
|||||||
self.app.include_router(route_to_web.router)
|
self.app.include_router(route_to_web.router)
|
||||||
self.app.include_router( image_service.router )
|
self.app.include_router( image_service.router )
|
||||||
|
|
||||||
|
def _setup_health_route(self):
|
||||||
|
@self.app.get("/health", tags=["Health"])
|
||||||
|
async def health_check():
|
||||||
|
return {"status": "ok"}
|
||||||
|
|
||||||
|
|
||||||
def _include_middelware(self):
|
def _include_middelware(self):
|
||||||
self.app.add_middleware( GZipMiddleware, minimum_size = 500 )
|
self.app.add_middleware( GZipMiddleware, minimum_size = 500 )
|
||||||
@@ -69,10 +75,6 @@ class Application:
|
|||||||
"""Return the FastAPI app instance."""
|
"""Return the FastAPI app instance."""
|
||||||
return self.app
|
return self.app
|
||||||
|
|
||||||
@app.get("/health")
|
|
||||||
async def health(self):
|
|
||||||
return {"status": "healthy"}
|
|
||||||
|
|
||||||
|
|
||||||
application = Application()
|
application = Application()
|
||||||
app = application.get_app()
|
app = application.get_app()
|
||||||
|
|||||||
Reference in New Issue
Block a user