21 lines
563 B
Python
21 lines
563 B
Python
|
import requests
|
||
|
import json
|
||
|
|
||
|
def slack_notification(message):
|
||
|
webhook_url = "https://hooks.slack.com/services/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"
|
||
|
slack_data = {"text": message}
|
||
|
|
||
|
response = requests.post(
|
||
|
webhook_url, data=json.dumps(slack_data),
|
||
|
headers={"Content-Type": "application/json"}
|
||
|
)
|
||
|
|
||
|
if response.status_code != 200:
|
||
|
raise ValueError(
|
||
|
f"Request to Slack returned an error {response.status_code}, {response.text}"
|
||
|
)
|
||
|
|
||
|
|
||
|
message = "Hello from Python!"
|
||
|
slack_notification(message)
|