mgbam commited on
Commit
d2f0104
·
verified ·
1 Parent(s): fb17746

Create templates/index.html

Browse files
Files changed (1) hide show
  1. templates/index.html +53 -0
templates/index.html ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>CryptoSentinel AI</title>
6
+ <script src="/static/htmx.min.js"></script>
7
+ <style>
8
+ body { font-family: system-ui, sans-serif; margin: 2rem; }
9
+ .price { font-size: 2rem; margin: .5rem 0; }
10
+ </style>
11
+ </head>
12
+ <body>
13
+ <h1>🛡️ CryptoSentinel AI</h1>
14
+
15
+ <section id="prices" hx-get="/prices" hx-trigger="load, every 10s" hx-swap="innerHTML">
16
+ <!-- Populated by HTMX -->
17
+ </section>
18
+
19
+ <hr>
20
+
21
+ <h2>Sentiment Lab</h2>
22
+ <input id="text" placeholder="Type something…" style="width:60%">
23
+ <button hx-post="/sentiment" hx-vals='js:{"text": document.getElementById("text").value}'
24
+ hx-swap="none">Analyze</button>
25
+
26
+ <pre id="sentiment-output">Waiting…</pre>
27
+
28
+ <script>
29
+ // EventSource for live sentiment push
30
+ const es = new EventSource("/sentiment/stream");
31
+ es.onmessage = e => {
32
+ const data = JSON.parse(e.data);
33
+ document.getElementById("sentiment-output").textContent =
34
+ JSON.stringify(data, null, 2);
35
+ };
36
+ </script>
37
+
38
+ <script>
39
+ // Template for price section (client-side rendering)
40
+ document.addEventListener("htmx:afterOnLoad", function(evt){
41
+ if (evt.detail.path === "/prices"){
42
+ const p = evt.detail.xhr.response;
43
+ const json = JSON.parse(p);
44
+ let html = '';
45
+ for (const [k,v] of Object.entries(json)){
46
+ html += `<div class="price">${k.toUpperCase()}: $${v}</div>`;
47
+ }
48
+ evt.detail.elt.innerHTML = html;
49
+ }
50
+ });
51
+ </script>
52
+ </body>
53
+ </html>