MYAPP / app.py
MadhavRupala's picture
Create app.py
ac57036 verified
raw
history blame contribute delete
830 Bytes
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)
@app.route("/")
def index():
return render_template("index.html")
@app.route("/upload", methods=["POST"])
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)