sample template
This commit is contained in:
parent
1d0f011171
commit
e6bb90f999
|
@ -3,3 +3,6 @@ email = email@fqdn
|
|||
email@fqdn.co.uk
|
||||
masonde_001@fqdn
|
||||
|
||||
|
||||
[test]
|
||||
email = notif_sondetest@monitoring.com
|
||||
|
|
14
papi/main.py
14
papi/main.py
|
@ -17,6 +17,8 @@ from papi.sqlapp import schemas
|
|||
|
||||
app = FastAPI()
|
||||
|
||||
templates = Jinja2Templates(directory="templates/")
|
||||
|
||||
|
||||
mesures = defaultdict(list)
|
||||
notifications = defaultdict(list)
|
||||
|
@ -95,14 +97,20 @@ def list_notification(idsonde: str):
|
|||
|
||||
|
||||
@app.get("/notifications/{idsonde}/text")
|
||||
def list_notification_as_text(idsonde: str):
|
||||
def list_notification_as_text(request: Request, idsonde: str):
|
||||
content = notifications[idsonde][-1]
|
||||
recipients = sondeid2notifsemails(idsonde)
|
||||
try:
|
||||
recipients = sondeid2notifsemails(idsonde)
|
||||
except KeyError:
|
||||
recipients = ["mail1@xxx", "mail2@xxx"]
|
||||
|
||||
changements = content["changes"]
|
||||
status = content["status"]
|
||||
|
||||
data = {"recipients": recipients, "changements": changements, "status": status}
|
||||
return data
|
||||
return templates.TemplateResponse(
|
||||
"notification_email.html", context={"request": request, "data": data}
|
||||
)
|
||||
|
||||
|
||||
@app.post("/sonde/{idsonde}/")
|
||||
|
|
Loading…
Reference in New Issue