Spaces:
Sleeping
Sleeping
Akshayram1
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -5,24 +5,25 @@ import pandas as pd
|
|
5 |
import plotly.express as px
|
6 |
from dateutil import parser
|
7 |
import nltk
|
8 |
-
nltk.
|
9 |
from nltk.sentiment.vader import SentimentIntensityAnalyzer
|
10 |
import datetime
|
11 |
import requests
|
12 |
|
13 |
st.set_page_config(page_title="Stock News Sentiment Analyzer", layout="wide")
|
14 |
|
15 |
-
# Function to
|
16 |
def set_headers():
|
17 |
-
|
18 |
-
st.
|
19 |
-
|
20 |
-
|
|
|
21 |
|
22 |
set_headers()
|
23 |
|
24 |
def verify_link(url, timeout=10, retries=3):
|
25 |
-
for _ in retries:
|
26 |
try:
|
27 |
response = requests.head(url, timeout=timeout, allow_redirects=True)
|
28 |
if 200 <= response.status_code < 300:
|
|
|
5 |
import plotly.express as px
|
6 |
from dateutil import parser
|
7 |
import nltk
|
8 |
+
nltk.download('vader_lexicon')
|
9 |
from nltk.sentiment.vader import SentimentIntensityAnalyzer
|
10 |
import datetime
|
11 |
import requests
|
12 |
|
13 |
st.set_page_config(page_title="Stock News Sentiment Analyzer", layout="wide")
|
14 |
|
15 |
+
# Function to set up headers
|
16 |
def set_headers():
|
17 |
+
# Adding meta tags for CORS and Content-Security-Policy
|
18 |
+
st.markdown("""
|
19 |
+
<meta http-equiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' 'unsafe-eval' data: gap: https://ssl.gstatic.com 'https://*'; connect-src * ws://localhost:* wss://localhost:*">
|
20 |
+
<meta http-equiv="Access-Control-Allow-Origin" content="*">
|
21 |
+
""", unsafe_allow_html=True)
|
22 |
|
23 |
set_headers()
|
24 |
|
25 |
def verify_link(url, timeout=10, retries=3):
|
26 |
+
for _ in range(retries): # Fixed the range usage
|
27 |
try:
|
28 |
response = requests.head(url, timeout=timeout, allow_redirects=True)
|
29 |
if 200 <= response.status_code < 300:
|