Spaces:
Paused
Paused
| from flask import Flask, render_template, request, redirect, url_for | |
| import os | |
| import subprocess | |
| app = Flask(__name__) | |
| UPLOAD_FOLDER = "/root/uploads" | |
| os.makedirs(UPLOAD_FOLDER, exist_ok=True) | |
| def index(): | |
| return render_template("index.html") | |
| def upload(): | |
| file = request.files["apkfile"] | |
| if file and file.filename.endswith(".apk"): | |
| filepath = os.path.join(UPLOAD_FOLDER, file.filename) | |
| file.save(filepath) | |
| # Install APK to emulator | |
| subprocess.run(["adb", "connect", "localhost:5555"]) | |
| subprocess.run(["adb", "install", "-r", filepath]) | |
| return f"✅ Installed {file.filename} successfully!" | |
| return "❌ Invalid file. Please upload an APK." | |
| if __name__ == "__main__": | |
| app.run(host="0.0.0.0", port=7860) | |