ayush2917 commited on
Commit
37a8c1a
·
verified ·
1 Parent(s): 8c1cdf7

Rename static/styles.css to static/index.html

Browse files
Files changed (2) hide show
  1. static/index.html +48 -0
  2. static/styles.css +0 -40
static/index.html ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>India News Fetcher</title>
6
+ <style>
7
+ body { font-family: Arial, sans-serif; margin: 20px; }
8
+ .article { border-bottom: 1px solid #ccc; padding: 10px; }
9
+ button { padding: 10px; margin: 5px; }
10
+ </style>
11
+ </head>
12
+ <body>
13
+ <h1>India News Fetcher</h1>
14
+ <button onclick="fetchNews('all')">All Topics</button>
15
+ <button onclick="fetchNews('Market trends,Cryptocurrency')">Market & Crypto</button>
16
+ <div id="news-container"></div>
17
+ <p>Last updated: <span id="last-updated">N/A</span></p>
18
+
19
+ <script>
20
+ async function fetchNews(topics) {
21
+ try {
22
+ const response = await fetch(`/news?topics=${topics}`);
23
+ const data = await response.json();
24
+ const container = document.getElementById('news-container');
25
+ container.innerHTML = '';
26
+ if (data.error) {
27
+ container.innerHTML = `<p>Error: ${data.error}</p>`;
28
+ } else {
29
+ data.articles.forEach(article => {
30
+ const div = document.createElement('div');
31
+ div.className = 'article';
32
+ div.innerHTML = `
33
+ <h2>${article.title}</h2>
34
+ <p><strong>Date:</strong> ${article.publishedAt}</p>
35
+ <p>${article.description}</p>
36
+ `;
37
+ container.appendChild(div);
38
+ });
39
+ document.getElementById('last-updated').textContent = data.last_updated;
40
+ }
41
+ } catch (error) {
42
+ document.getElementById('news-container').innerHTML = `<p>Error fetching news: ${error.message}</p>`;
43
+ }
44
+ }
45
+ fetchNews('all'); // Load news on page load
46
+ </script>
47
+ </body>
48
+ </html>
static/styles.css DELETED
@@ -1,40 +0,0 @@
1
- body {
2
- font-family: Arial, sans-serif;
3
- background-color: #f4f4f4;
4
- margin: 0;
5
- padding: 20px;
6
- }
7
-
8
- .container {
9
- max-width: 800px;
10
- margin: 0 auto;
11
- background: white;
12
- padding: 20px;
13
- border-radius: 5px;
14
- box-shadow: 0 0 10px rgba(0,0,0,0.1);
15
- }
16
-
17
- h1 {
18
- color: #333;
19
- text-align: center;
20
- }
21
-
22
- .article {
23
- border-bottom: 1px solid #ddd;
24
- padding: 10px 0;
25
- }
26
-
27
- .article h2 {
28
- margin: 0;
29
- font-size: 18px;
30
- color: #0066cc;
31
- }
32
-
33
- .article p {
34
- margin: 5px 0;
35
- color: #666;
36
- }
37
-
38
- .article:last-child {
39
- border-bottom: none;
40
- }