banao-tech commited on
Commit
ec1271c
·
verified ·
1 Parent(s): 168f9ee

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -0
app.py CHANGED
@@ -15,6 +15,7 @@ from contextlib import asynccontextmanager
15
 
16
  from fastapi import FastAPI, Request
17
  from fastapi.responses import JSONResponse
 
18
  from pydantic import BaseModel
19
 
20
  import router
@@ -51,6 +52,14 @@ app = FastAPI(
51
  lifespan=lifespan,
52
  )
53
 
 
 
 
 
 
 
 
 
54
  SLACK_SIGNING_SECRET = os.environ.get("SLACK_SIGNING_SECRET", "")
55
  CHANNEL_ID = os.environ.get("SLACK_CHANNEL_ID", "")
56
 
@@ -264,6 +273,34 @@ async def delete_intern(candidate_id: str):
264
  except Exception as e:
265
  return JSONResponse({"error": str(e)}, status_code=500)
266
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
267
  @app.get("/health", summary="Health check")
268
  async def health():
269
  return JSONResponse({"status": "ok"})
 
15
 
16
  from fastapi import FastAPI, Request
17
  from fastapi.responses import JSONResponse
18
+ from fastapi.middleware.cors import CORSMiddleware
19
  from pydantic import BaseModel
20
 
21
  import router
 
52
  lifespan=lifespan,
53
  )
54
 
55
+ app.add_middleware(
56
+ CORSMiddleware,
57
+ allow_origins=["*"], # restrict to your dashboard URL in production
58
+ allow_credentials=True,
59
+ allow_methods=["*"],
60
+ allow_headers=["*"],
61
+ )
62
+
63
  SLACK_SIGNING_SECRET = os.environ.get("SLACK_SIGNING_SECRET", "")
64
  CHANNEL_ID = os.environ.get("SLACK_CHANNEL_ID", "")
65
 
 
273
  except Exception as e:
274
  return JSONResponse({"error": str(e)}, status_code=500)
275
 
276
+
277
+ @app.post("/admin/trigger_agenda", summary="Manually trigger morning agenda prompt")
278
+ async def trigger_agenda():
279
+ """Trigger the 9 AM agenda prompt manually — for testing."""
280
+ try:
281
+ import threading
282
+ import scheduler as sched
283
+ thread = threading.Thread(target=sched.job_morning_agenda_prompt)
284
+ thread.daemon = True
285
+ thread.start()
286
+ return JSONResponse({"ok": True, "message": "Agenda prompt triggered"})
287
+ except Exception as e:
288
+ return JSONResponse({"error": str(e)}, status_code=500)
289
+
290
+
291
+ @app.post("/admin/trigger_summary", summary="Manually trigger EOD summary and miss check")
292
+ async def trigger_summary():
293
+ """Trigger the 11:30 PM miss check and summary manually — for testing."""
294
+ try:
295
+ import threading
296
+ import handlers
297
+ thread = threading.Thread(target=handlers.handle_missed_report_check)
298
+ thread.daemon = True
299
+ thread.start()
300
+ return JSONResponse({"ok": True, "message": "Miss check and summary triggered"})
301
+ except Exception as e:
302
+ return JSONResponse({"error": str(e)}, status_code=500)
303
+
304
  @app.get("/health", summary="Health check")
305
  async def health():
306
  return JSONResponse({"status": "ok"})