File size: 2,127 Bytes
05cf3a9
 
 
 
 
 
 
 
 
3181725
 
 
 
 
 
 
 
 
 
 
 
dafa13c
3181725
 
1bfaf7d
3181725
 
 
ac68956
 
 
 
dafa13c
3181725
95ff377
 
3181725
 
 
 
ac68956
3181725
ac68956
3181725
 
615cdc3
 
3181725
 
 
 
05cf3a9
 
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
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width" />
		<title>My static Space</title>
		<link rel="stylesheet" href="style.css" />
	</head>
	<body>
        <header>
          <h1>Stance Prediction on Latest News</h1>
        </header>
        <nav>
          <ul>
            <li><a href="https://modal.com/apps/dhruvshettty/biweekly_pipeline">Modal Biweekly Pipeline</a></li>
            <li><a href="https://modal.com/apps/dhruvshettty/daily_pipeline">Modal Daily Pipeline</a></li>
            <li><a href="https://modal.com/apps/dhruvshettty/latest_news_webhook">Modal Articles Webhook</a></li>
          </ul>
        </nav>
        <section id="main-content">
          <button id="get-articles" type="button">Get recent articles...</button>
          <div id="message-container">Getting articles...</div>
        </section>

        <script>
          const endpoint = 'https://dhruvshettty--latest-news-webhook-response-articles.modal.run/';
          
          document.getElementById("get-articles").onclick = function() {
              var message = document.getElementById("message-container");
              message.style.display = 'block';
              setTimeout(function() { 
                message.style.display = 'none'; 
              }, 5000);
            fetch(endpoint)
              .then((response) => response.json())
              .then((data) => {
                const mainContent = document.getElementById("main-content");
                data.forEach(post => {
                  const article = document.createElement('article');
                  article.innerHTML = `
                    <a href="${post.url}"><h2>${post.title}</h2></a>
                    <p>Published on ${post.publishedat}</p>
                    <p>Categories: [${post.predicted_topic}]</p>
                    <p>Stance: ${post.predicted_stance}</p>
                  `;
                  mainContent.appendChild(article);
                });
              })
              .catch(error => console.error(error));
          }
        </script>
	</body>
</html>