Spaces:
Paused
Paused
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, render_template, request, redirect, url_for
|
| 2 |
+
import os
|
| 3 |
+
import subprocess
|
| 4 |
+
|
| 5 |
+
app = Flask(__name__)
|
| 6 |
+
UPLOAD_FOLDER = "/root/uploads"
|
| 7 |
+
os.makedirs(UPLOAD_FOLDER, exist_ok=True)
|
| 8 |
+
|
| 9 |
+
@app.route("/")
|
| 10 |
+
def index():
|
| 11 |
+
return render_template("index.html")
|
| 12 |
+
|
| 13 |
+
@app.route("/upload", methods=["POST"])
|
| 14 |
+
def upload():
|
| 15 |
+
file = request.files["apkfile"]
|
| 16 |
+
if file and file.filename.endswith(".apk"):
|
| 17 |
+
filepath = os.path.join(UPLOAD_FOLDER, file.filename)
|
| 18 |
+
file.save(filepath)
|
| 19 |
+
# Install APK to emulator
|
| 20 |
+
subprocess.run(["adb", "connect", "localhost:5555"])
|
| 21 |
+
subprocess.run(["adb", "install", "-r", filepath])
|
| 22 |
+
return f"✅ Installed {file.filename} successfully!"
|
| 23 |
+
return "❌ Invalid file. Please upload an APK."
|
| 24 |
+
|
| 25 |
+
if __name__ == "__main__":
|
| 26 |
+
app.run(host="0.0.0.0", port=7860)
|