mirror of
https://github.com/dat515-2025/Group-8.git
synced 2026-03-22 15:12:08 +01:00
feat(deployment): add 404 for public access
This commit is contained in:
@@ -5,7 +5,7 @@ import sys
|
||||
from datetime import datetime
|
||||
from pythonjsonlogger import jsonlogger
|
||||
|
||||
from fastapi import Depends, FastAPI
|
||||
from fastapi import Depends, FastAPI, HTTPException
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from prometheus_fastapi_instrumentator import Instrumentator, metrics
|
||||
from starlette.requests import Request
|
||||
@@ -162,7 +162,10 @@ async def authenticated_route(user: User = Depends(current_active_verified_user)
|
||||
|
||||
@fastApi.get("/_cron", include_in_schema=False)
|
||||
async def handle_cron(request: Request):
|
||||
# endpoint accessed by Clodflare => return 404
|
||||
if request.headers.get("cf-connecting-ip"):
|
||||
raise HTTPException(status_code=404)
|
||||
|
||||
logging.info("[Cron] Triggering scheduled tasks via HTTP endpoint")
|
||||
logging.info(json.dumps(request.headers.__str__()))
|
||||
task = load_all_transactions.delay()
|
||||
return {"status": "queued", "action": "csas_scrape_all", "task_id": getattr(task, 'id', None)}
|
||||
|
||||
Reference in New Issue
Block a user