Download deployment/aws/lambda/status_api.py from Wizzas/DefectRAG: direct link, hf CLI and curl.
- Browser
- Download file 1.37 kB
-
https://huggingface.co/Wizzas/DefectRAG/resolve/ecb2a3f4a67e1aec2e445efe43c0f241176875ff/deployment/aws/lambda/status_api.py
- Command line
-
hf download hf://Wizzas/DefectRAG@ecb2a3f4a67e1aec2e445efe43c0f241176875ff/deployment/aws/lambda/status_api.py
-
curl -L -o status_api.py https://huggingface.co/Wizzas/DefectRAG/resolve/ecb2a3f4a67e1aec2e445efe43c0f241176875ff/deployment/aws/lambda/status_api.py
1.37 kB
| """Lambda behind a Function URL: returns a small public status document. | |
| Runtime: Python 3.12. Handler: status_api.handler. No environment variables are required. | |
| It only returns harmless public facts, so the URL can use auth type NONE. | |
| Set reserved concurrency to a small number (for example 5) to cap cost and abuse. | |
| """ | |
| import json | |
| import os | |
| from datetime import datetime, timezone | |
| SAVED_EXAMPLES = 24 # the showcase ships 24 saved real inspections (2 per product, tuned detector) | |
| def handler(event, context): | |
| method = (event.get("requestContext", {}).get("http", {}).get("method") or "GET").upper() | |
| headers = { | |
| "Content-Type": "application/json", | |
| "Cache-Control": "no-store", | |
| "Access-Control-Allow-Origin": "*", | |
| "Access-Control-Allow-Methods": "GET, OPTIONS", | |
| } | |
| if method == "OPTIONS": | |
| return {"statusCode": 204, "headers": headers, "body": ""} | |
| if method != "GET": | |
| return {"statusCode": 405, "headers": headers, "body": json.dumps({"error": "Use GET"})} | |
| body = { | |
| "service": "DefectRAG showcase", | |
| "status": "ok", | |
| "saved_examples": SAVED_EXAMPLES, | |
| "time": datetime.now(timezone.utc).strftime("%Y-%m-%d %H:%M:%S"), | |
| "region": os.environ.get("AWS_REGION", "unknown"), | |
| } | |
| return {"statusCode": 200, "headers": headers, "body": json.dumps(body)} | |