From 4aa13863d8868b3987ca9c541c8e38e9095451d8 Mon Sep 17 00:00:00 2001 From: Aasher Kataria <75544234+aasherkataria@users.noreply.github.com> Date: Sat, 9 Nov 2024 16:55:34 -0600 Subject: [PATCH] added status check endpoint (#42) --- modules/api/api.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/modules/api/api.py b/modules/api/api.py index f468c3852..5352b8838 100644 --- a/modules/api/api.py +++ b/modules/api/api.py @@ -209,6 +209,10 @@ class Api: self.queue_lock = queue_lock api_middleware(self.app) self.add_api_route("/sdapi/v1/txt2img", self.text2imgapi, methods=["POST"], response_model=models.TextToImageResponse) + + # Add health check endpoint + self.add_api_route("/sdapi/v1/status", self.health_check, methods=["GET"]) + self.add_api_route("/sdapi/v1/img2img", self.img2imgapi, methods=["POST"], response_model=models.ImageToImageResponse) self.add_api_route("/sdapi/v1/extra-single-image", self.extras_single_image_api, methods=["POST"], response_model=models.ExtrasSingleImageResponse) self.add_api_route("/sdapi/v1/extra-batch-images", self.extras_batch_images_api, methods=["POST"], response_model=models.ExtrasBatchImagesResponse) @@ -270,6 +274,9 @@ class Api: self.default_script_arg_img2img = self.init_default_script_args(img2img_script_runner) + # Health check endpoint method + async def health_check(self): + return JSONResponse(content={"status": "Server is running"}, status_code=200) def add_api_route(self, path: str, endpoint, **kwargs): if shared.cmd_opts.api_auth: