Skip to content

Commit

Permalink
chore: status/http README
Browse files Browse the repository at this point in the history
  • Loading branch information
hshaosf committed Jan 7, 2025
1 parent 63239b1 commit cbad20a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,19 @@ Example query `property_street_number`, `property_street_number_sfx`, `property_
$ curl https://<host>/api/abe/json?$select=property_street_number,property_street_number_sfx,property_street_name,property_street_sfx,property_unit,block,lot&$where=block%20=%270834%27%20AND%20lot=%27144%27
```

## `api/status/http`

Query http status of the serverless function.

### Query

Example

```sh
curl https://<host>/api/status/http

{"status": "success", "data": {"message": "200 OK"}}
```

## Deployment notes
#### :warning: [Linux Consumption] Successful slot swaps automatically reverted after a few minutes :warning:
Expand Down
16 changes: 8 additions & 8 deletions status_http/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
""" status/http init file """

import os
import json
import logging
Expand All @@ -9,26 +10,25 @@
from requests.models import Response
from shared_code.common import func_jsend_response


def main(req: func.HttpRequest) -> func.HttpResponse:
""" main function for status/http """
logging.info('Status processed a request.')
"""main function for status/http"""
logging.info("Status processed a request.")

try:
if req.get_body() and len(req.get_body()):
status_code = 202
# pylint: disable=protected-access
body = "202 Accepted"
body = {"message": "202 Accepted"}
else:
status_code = 200
# pylint: disable=protected-access
body = "200 OK"
body = {"message": "200 OK"}

headers = {
"Access-Control-Allow-Origin": "*"
}
headers = {"Access-Control-Allow-Origin": "*"}
return func_jsend_response(body, headers, status_code)

#pylint: disable=broad-except
# pylint: disable=broad-except
except Exception as err:
logging.error("Status HTTP error occurred: %s", traceback.format_exc())
msg_error = f"This endpoint encountered an error. {err}"
Expand Down

0 comments on commit cbad20a

Please sign in to comment.