measmonysuon commited on
Commit
a661009
1 Parent(s): d2adc3f

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +12 -3
index.html CHANGED
@@ -8,13 +8,19 @@
8
  // Initialize the Telegram Web App
9
  window.Telegram.WebApp.init();
10
 
11
- // Example: Get user data
12
  const user = window.Telegram.WebApp.initDataUnsafe.user;
13
  console.log('Telegram user data:', user);
14
 
15
- // Example: Set a custom title for the app
 
 
 
16
  window.Telegram.WebApp.setTitle("My Gradio App");
17
 
 
 
 
18
  // Example: Handle button click
19
  document.getElementById('my-button').addEventListener('click', function() {
20
  window.Telegram.WebApp.close();
@@ -23,7 +29,10 @@
23
  </script>
24
  </head>
25
  <body>
 
26
  <!-- Gradio app iframe -->
27
- <iframe src="https://measmonysuon-WebApp.hf.space" width="100%" height="600px"></iframe>
 
 
28
  </body>
29
  </html>
 
8
  // Initialize the Telegram Web App
9
  window.Telegram.WebApp.init();
10
 
11
+ // Get user data
12
  const user = window.Telegram.WebApp.initDataUnsafe.user;
13
  console.log('Telegram user data:', user);
14
 
15
+ // Extract username
16
+ const username = user ? user.username : 'Guest';
17
+
18
+ // Set a custom title for the app
19
  window.Telegram.WebApp.setTitle("My Gradio App");
20
 
21
+ // Display welcome message
22
+ document.getElementById('welcome-message').textContent = `Welcome, ${username}!`;
23
+
24
  // Example: Handle button click
25
  document.getElementById('my-button').addEventListener('click', function() {
26
  window.Telegram.WebApp.close();
 
29
  </script>
30
  </head>
31
  <body>
32
+ <h1 id="welcome-message">Welcome, Guest!</h1>
33
  <!-- Gradio app iframe -->
34
+ <iframe src="https://your-gradio-app-url" width="100%" height="600px"></iframe>
35
+ <!-- Optional button to close the app -->
36
+ <button id="my-button">Close</button>
37
  </body>
38
  </html>