74 lines
2.7 KiB
Plaintext
74 lines
2.7 KiB
Plaintext
from flask import Flask, jsonify, render_template_string
|
|
import subprocess
|
|
import json
|
|
|
|
app = Flask(__name__)
|
|
|
|
@app.route('/')
|
|
def index():
|
|
return render_template_string('''
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>SMS Campaign Manager - Termux</title>
|
|
<style>
|
|
body { font-family: Arial, sans-serif; margin: 40px; background: #f5f5f5; }
|
|
.container { background: white; padding: 30px; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
|
|
.status { background: #e8f5e8; padding: 20px; border-radius: 8px; margin: 20px 0; }
|
|
.api-test { background: #f0f8ff; padding: 15px; border-radius: 5px; margin: 10px 0; }
|
|
a { color: #0066cc; text-decoration: none; }
|
|
a:hover { text-decoration: underline; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="container">
|
|
<h1>🚀 SMS Campaign Manager</h1>
|
|
<h2>Running on Termux!</h2>
|
|
|
|
<div class="status">
|
|
<h3>✅ Flask Server Status: Active</h3>
|
|
<p><strong>Server IP:</strong> 10.0.0.193:5000</p>
|
|
<p><strong>Environment:</strong> Termux on Android</p>
|
|
</div>
|
|
|
|
<div class="api-test">
|
|
<h3>🔋 Termux API Tests</h3>
|
|
<p><a href="/battery">📱 Battery Status</a></p>
|
|
<p><a href="/notification">🔔 Send Test Notification</a></p>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
''')
|
|
|
|
@app.route('/battery')
|
|
def battery():
|
|
try:
|
|
result = subprocess.run(['termux-battery-status'], capture_output=True, text=True)
|
|
battery_data = json.loads(result.stdout)
|
|
return f"""
|
|
<h2>🔋 Battery Status</h2>
|
|
<pre>{json.dumps(battery_data, indent=2)}</pre>
|
|
<p><a href='/'>← Back</a></p>
|
|
"""
|
|
except Exception as e:
|
|
return f"<h2>Error</h2><pre>{str(e)}</pre><p><a href='/'>← Back</a></p>"
|
|
|
|
@app.route('/notification')
|
|
def notification():
|
|
try:
|
|
subprocess.run(['termux-notification', '--title', 'Flask Test', '--content', 'Hello from SMS Campaign Manager!'], capture_output=True, text=True)
|
|
return f"""
|
|
<h2>🔔 Notification Sent!</h2>
|
|
<p>Check your Android notifications.</p>
|
|
<p><a href='/'>← Back</a></p>
|
|
"""
|
|
except Exception as e:
|
|
return f"<h2>Error</h2><pre>{str(e)}</pre><p><a href='/'>← Back</a></p>"
|
|
|
|
if __name__ == '__main__':
|
|
print("🚀 Starting SMS Campaign Manager on Termux...")
|
|
print("📱 Device IP: 10.0.0.193")
|
|
print("🌐 Access from Ubuntu: http://10.0.0.193:5000")
|
|
app.run(host='0.0.0.0', port=5000, debug=True)
|