Akshayram1 commited on
Commit
ac01bd6
·
verified ·
1 Parent(s): 5f04129

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -7
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.downloader.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 allow all CORS and permissions, managed typically by your server or hosting service.
16
  def set_headers():
17
- st.write("<head>")
18
- st.write("""<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:*">""")
19
- st.write("<meta http-equiv='Access-Control-Allow-Origin' content='*'>")
20
- st.write("</head>")
 
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: