Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions web_programming/fetch_bbc_news.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import requests

# Enter Your API Key in following URL
_NEWS_API = "https://newsapi.org/v1/articles?source=bbc-news&sortBy=top&apiKey="


Expand All @@ -14,5 +13,5 @@ def fetch_bbc_news(bbc_news_api_key: str) -> None:
print(f"{i}.) {article['title']}")


if __name__ == '__main__':
if __name__ == "__main__":
fetch_bbc_news(bbc_news_api_key="<Your BBC News API key goes here>")
18 changes: 18 additions & 0 deletions web_programming/slack_message.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Created by sarathkaul on 12/11/19

import requests


def send_slack_message(message_body: str, slack_url: str) -> None:
headers = {"Content-Type": "application/json"}
response = requests.post(slack_url, json={"text": message_body}, headers=headers)
if response.status_code != 200:
raise ValueError(
f"Request to slack returned an error {response.status_code}, "
f"the response is:\n{response.text}"
)


if __name__ == "main":
# Set the slack url to the one provided by Slack when you create the webhook at https://my.slack.com/services/new/incoming-webhook/
send_slack_message("<YOUR MESSAGE BODY>", "<SLACK CHANNEL URL>")