Spaces:
Running
Running
app.py
CHANGED
|
@@ -6,7 +6,6 @@ import uvicorn
|
|
| 6 |
|
| 7 |
# --- Security Dependency ---
|
| 8 |
|
| 9 |
-
# 1. Retrieve the server-side access key from the environment variable 'AK'
|
| 10 |
ACCESS_KEY = os.environ.get("AK")
|
| 11 |
|
| 12 |
async def verify_access_key(ak: str = Query(..., alias="AK")):
|
|
@@ -35,6 +34,15 @@ app = FastAPI(
|
|
| 35 |
)
|
| 36 |
|
| 37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
@app.get("/ping", response_class=PlainTextResponse)
|
| 39 |
async def ping():
|
| 40 |
"""
|
|
@@ -70,6 +78,3 @@ async def fetch_url_content(request: Request):
|
|
| 70 |
except httpx.HTTPStatusError as exc:
|
| 71 |
raise HTTPException(status_code=exc.response.status_code, detail=f"Error response {exc.response.status_code} while requesting {exc.request.url!r}.")
|
| 72 |
|
| 73 |
-
|
| 74 |
-
#if __name__ == "__main__":
|
| 75 |
-
# uvicorn.run(app, host="0.0.0.0", port=7860)
|
|
|
|
| 6 |
|
| 7 |
# --- Security Dependency ---
|
| 8 |
|
|
|
|
| 9 |
ACCESS_KEY = os.environ.get("AK")
|
| 10 |
|
| 11 |
async def verify_access_key(ak: str = Query(..., alias="AK")):
|
|
|
|
| 34 |
)
|
| 35 |
|
| 36 |
|
| 37 |
+
# --- MODIFIED: Root Endpoint ---
|
| 38 |
+
@app.get("/", response_class=PlainTextResponse)
|
| 39 |
+
async def root():
|
| 40 |
+
"""
|
| 41 |
+
Root endpoint for health checks. Returns a simple 'OK' response.
|
| 42 |
+
"""
|
| 43 |
+
return "OK"
|
| 44 |
+
|
| 45 |
+
|
| 46 |
@app.get("/ping", response_class=PlainTextResponse)
|
| 47 |
async def ping():
|
| 48 |
"""
|
|
|
|
| 78 |
except httpx.HTTPStatusError as exc:
|
| 79 |
raise HTTPException(status_code=exc.response.status_code, detail=f"Error response {exc.response.status_code} while requesting {exc.request.url!r}.")
|
| 80 |
|
|
|
|
|
|
|
|
|