Spaces:
Sleeping
Sleeping
deepak191z
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,7 @@ import streamlit as st
|
|
2 |
import os
|
3 |
import subprocess
|
4 |
import shutil
|
|
|
5 |
|
6 |
# Function to process APK file
|
7 |
def process_apk(input_path, output_dir):
|
@@ -15,17 +16,33 @@ st.title("APK File Processor")
|
|
15 |
|
16 |
# File upload
|
17 |
uploaded_file = st.file_uploader("Upload APK file", type="apk")
|
18 |
-
|
|
|
|
|
|
|
|
|
19 |
# Create directories if they don't exist
|
20 |
upload_dir = "uploads"
|
21 |
if not os.path.exists(upload_dir):
|
22 |
os.makedirs(upload_dir)
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
# Define output directory for the patched APK
|
30 |
output_dir = upload_dir
|
31 |
|
@@ -36,7 +53,7 @@ if uploaded_file is not None:
|
|
36 |
if result.returncode == 0:
|
37 |
st.success("APK processed successfully!")
|
38 |
st.write("Processing result:")
|
39 |
-
|
40 |
|
41 |
# Extract the patched APK file name from the stdout
|
42 |
output_file_name = result.stdout.split("Patched file: ")[-1].strip()
|
|
|
2 |
import os
|
3 |
import subprocess
|
4 |
import shutil
|
5 |
+
import requests
|
6 |
|
7 |
# Function to process APK file
|
8 |
def process_apk(input_path, output_dir):
|
|
|
16 |
|
17 |
# File upload
|
18 |
uploaded_file = st.file_uploader("Upload APK file", type="apk")
|
19 |
+
|
20 |
+
# URL upload
|
21 |
+
url_input = st.text_input("Or enter APK URL")
|
22 |
+
|
23 |
+
if uploaded_file is not None or url_input:
|
24 |
# Create directories if they don't exist
|
25 |
upload_dir = "uploads"
|
26 |
if not os.path.exists(upload_dir):
|
27 |
os.makedirs(upload_dir)
|
28 |
|
29 |
+
if uploaded_file is not None:
|
30 |
+
# Save uploaded file
|
31 |
+
input_path = os.path.join(upload_dir, uploaded_file.name)
|
32 |
+
with open(input_path, "wb") as f:
|
33 |
+
f.write(uploaded_file.read())
|
34 |
+
elif url_input:
|
35 |
+
# Download APK from URL
|
36 |
+
st.write("Downloading APK from URL...")
|
37 |
+
response = requests.get(url_input)
|
38 |
+
if response.status_code == 200:
|
39 |
+
input_path = os.path.join(upload_dir, os.path.basename(url_input))
|
40 |
+
with open(input_path, "wb") as f:
|
41 |
+
f.write(response.content)
|
42 |
+
else:
|
43 |
+
st.error("Failed to download APK from URL. Please check the URL and try again.")
|
44 |
+
st.stop()
|
45 |
+
|
46 |
# Define output directory for the patched APK
|
47 |
output_dir = upload_dir
|
48 |
|
|
|
53 |
if result.returncode == 0:
|
54 |
st.success("APK processed successfully!")
|
55 |
st.write("Processing result:")
|
56 |
+
st.text(result.stdout)
|
57 |
|
58 |
# Extract the patched APK file name from the stdout
|
59 |
output_file_name = result.stdout.split("Patched file: ")[-1].strip()
|