measmonysuon commited on
Commit
ca7569e
1 Parent(s): 235e58e

Create index.html

Browse files
Files changed (1) hide show
  1. index.html +38 -0
index.html ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>My Gradio App</title>
5
+ <script src="https://telegram.org/js/telegram-web-app.js"></script>
6
+ <script>
7
+ document.addEventListener('DOMContentLoaded', function() {
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();
27
+ });
28
+ });
29
+ </script>
30
+ </head>
31
+ <body>
32
+ <h1 id="welcome-message">Welcome, Guest!</h1>
33
+ <!-- Gradio app iframe -->
34
+ <iframe src="https://measmonysuon-WebApp.hf.space" width="100%" height="600px"></iframe>
35
+ <!-- Optional button to close the app -->
36
+ <button id="my-button">Close</button>
37
+ </body>
38
+ </html>