-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiteration1.py
62 lines (40 loc) · 2.18 KB
/
iteration1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import requests
import streamlit as st
import streamlit.components.v1 as stc
from pretty_notification_box import notification_box
import time
# News API configuration
API_KEY = '***************************************'
API_ENDPOINT = 'https://newsapi.org/v2/top-headlines'
COUNTRY_CODE = 'us'
def get_news():
params = {
'country': COUNTRY_CODE,
'apiKey': API_KEY
}
response = requests.get(API_ENDPOINT, params=params)
data = response.json()
return data['articles']
st.title('Latest News')
st.sidebar.markdown("""<div style="background-color:#FF5733;color:#FFFFFF;padding:10px;border-radius:5px;"><strong>⚠️Doomscrolling Warning:</strong> Are you doomscrolling? What about taking a short screen break and looking away from your computer? There might be many more news updates, but you still deserve time to rest.!</div>""", unsafe_allow_html=True)
def mir():
articles = get_news()
for article in articles:
st.write('## ' + article['title'])
st.write(article['description'])
st.write(article['source']['name'])
st.write(article['url'])
st.image(article['urlToImage'])
st.markdown('---')
mir()
styles = {'material-icons':{'color': 'red'},
'title': {'font-weight':'bold'},
'notification-content-container': {'':''},
'title-text-url-container': {'',''},
'notification-text-link-close-container': {'',''},
'external-link': {'',''},
'close-button': {'',''}}
def doom():
time.sleep(30)
notification_box(icon='warning', title='Warning', textDisplay='This is a Doomscrolling Warning', externalLink='view more details', url='https://www.sciencealert.com/here-s-what-doomscrolling-is-doing-to-your-brain-and-how-to-fix-the-problem', styles=None, key='foo')
doom()