nick5363 commited on
Commit
6277d1f
·
verified ·
1 Parent(s): c822e58

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -19
app.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  import requests
3
  import feedparser
4
  import gradio as gr
@@ -9,10 +8,6 @@ def get_combined_news():
9
  result = "\n\n"
10
  index = 1
11
 
12
-
13
-
14
-
15
- # VnExpress Kinh Doanh
16
  try:
17
  vnexpress_url = "https://vnexpress.net/rss/kinh-doanh.rss"
18
  vn_feed = feedparser.parse(vnexpress_url)
@@ -21,8 +16,7 @@ def get_combined_news():
21
  index += 1
22
  except:
23
  result += "*Lỗi khi lấy tin từ VnExpress*\n\n"
24
-
25
- # Marketaux
26
  try:
27
  url = f"https://api.marketaux.com/v1/news/all?language=en&limit=3&api_token={API_KEY}"
28
  data = requests.get(url).json()
@@ -36,7 +30,6 @@ def get_combined_news():
36
  except:
37
  result += "*Lỗi khi lấy từ Marketaux*\n\n"
38
 
39
- # Google RSS (Yahoo Finance)
40
  try:
41
  feed_url = "https://news.google.com/rss/search?q=site:finance.yahoo.com&hl=en-US&gl=US&ceid=US:en"
42
  feed = feedparser.parse(feed_url)
@@ -47,20 +40,14 @@ def get_combined_news():
47
  result += "*Lỗi khi lấy từ Google RSS*\n\n"
48
 
49
  return result
50
-
51
 
52
- # Tự động load luôn khi mở web (live=True)
53
- # Giao diện Gradio với theme tối + tự chạy
54
- theme = gr.themes.Base().set(
55
- body_background_fill="#000000", # nền đen
56
- body_text_color="#ffffff", # chữ trắng
57
- )
58
 
59
  gr.Interface(
60
  fn=get_combined_news,
61
  inputs=None,
62
  outputs="markdown",
63
- live=True, # tự động chạy khi mở web
64
- theme=theme,
65
-
66
- ).launch()
 
 
1
  import requests
2
  import feedparser
3
  import gradio as gr
 
8
  result = "\n\n"
9
  index = 1
10
 
 
 
 
 
11
  try:
12
  vnexpress_url = "https://vnexpress.net/rss/kinh-doanh.rss"
13
  vn_feed = feedparser.parse(vnexpress_url)
 
16
  index += 1
17
  except:
18
  result += "*Lỗi khi lấy tin từ VnExpress*\n\n"
19
+
 
20
  try:
21
  url = f"https://api.marketaux.com/v1/news/all?language=en&limit=3&api_token={API_KEY}"
22
  data = requests.get(url).json()
 
30
  except:
31
  result += "*Lỗi khi lấy từ Marketaux*\n\n"
32
 
 
33
  try:
34
  feed_url = "https://news.google.com/rss/search?q=site:finance.yahoo.com&hl=en-US&gl=US&ceid=US:en"
35
  feed = feedparser.parse(feed_url)
 
40
  result += "*Lỗi khi lấy từ Google RSS*\n\n"
41
 
42
  return result
 
43
 
44
+ # Dùng dark theme chuẩn trong Gradio mới
45
+ dark_theme = gr.themes.Soft(primary_hue="blue", neutral_hue="gray")
 
 
 
 
46
 
47
  gr.Interface(
48
  fn=get_combined_news,
49
  inputs=None,
50
  outputs="markdown",
51
+ live=True,
52
+ theme=dark_theme,
53
+ ).launch(share=True)