gotifyhook/application.py
2022-08-26 14:26:49 +00:00

30 lines
784 B
Python

from urllib.request import Request
from gotify import Gotify
from classes.config import Config
def send_message(gotify_url: str, token: str, content: str, title: str = "Webhook", priority: int = 0):
gotify = Gotify(
base_url=gotify_url,
app_token=token,
)
gotify.create_message(
content,
title=title,
priority=priority,
)
def application(env, start_response):
config = Config()
try:
send_message(config.gotify_url, config.token, config.message, config.title, config.priority)
start_response('200 OK', [('Content-Type','text/html')])
return "200 OK".encode()
except Exception as e:
start_response('500 Internal Server Error')
return "500 Internal Server Error".encode()