Exe-To-Apk-2 / app.py
Peeble's picture
Update app.py
97558f3 verified
import gradio as gr
import requests
PORTED_SERVER_URL = "http://192.168.1.100:5000/upload"
def convert_exe_to_apk(file_path):
try:
with open(file_path, "rb") as f:
files = {"file": f}
response = requests.post(PORTED_SERVER_URL, files=files)
if response.status_code == 200:
apk_url = response.json().get("apk_url", None)
if apk_url:
return apk_url, gr.update(visible=True) # Show the button
else:
return f"❌ Server Error: {response.json().get('error', 'Unknown Error')}", gr.update(visible=False)
except Exception as e:
return f"❌ Failed to upload: {str(e)}", gr.update(visible=False)
with gr.Blocks() as app:
gr.Markdown("## EXE to APK Converter")
upload_button = gr.File(label="Upload EXE File", type="filepath") # ✅ Corrected type
output_text = gr.Textbox(label="Download Link", interactive=False) # Shows the URL
download_button = gr.Button("Download APK", visible=False) # Initially hidden
upload_button.change(convert_exe_to_apk, inputs=upload_button, outputs=[output_text, download_button])
app.launch()