Peeble commited on
Commit
82ac893
·
verified ·
1 Parent(s): c87fca9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -13
app.py CHANGED
@@ -3,30 +3,25 @@ import requests
3
 
4
  PORTED_SERVER_URL = "http://192.168.1.100:5000/upload"
5
 
6
- def convert_exe_to_apk(file):
7
- files = {"file": file}
8
- response = requests.post(PORTED_SERVER_URL, files=files)
 
9
 
10
  if response.status_code == 200:
11
  apk_url = response.json().get("apk_url", None)
12
  if apk_url:
13
- return apk_url # Return the direct APK URL
14
- return "❌ Error converting EXE to APK."
15
 
16
  with gr.Blocks() as app:
17
  gr.Markdown("## EXE to APK Converter")
18
 
19
- upload_button = gr.File(label="Upload EXE File", type="file")
20
  output_text = gr.Textbox(label="Download Link", interactive=False) # Shows the URL
21
  download_button = gr.Button("Download APK", visible=False) # Initially hidden
22
 
23
- def process_file(file):
24
- apk_url = convert_exe_to_apk(file)
25
- if "http" in apk_url:
26
- return apk_url, gr.update(visible=True) # Show the button
27
- return "❌ Conversion failed", gr.update(visible=False)
28
-
29
- upload_button.change(process_file, inputs=upload_button, outputs=[output_text, download_button])
30
 
31
  def open_download(url):
32
  return gr.update(value=f"[Click Here to Download]({url})")
 
3
 
4
  PORTED_SERVER_URL = "http://192.168.1.100:5000/upload"
5
 
6
+ def convert_exe_to_apk(file_path):
7
+ with open(file_path, "rb") as f:
8
+ files = {"file": f}
9
+ response = requests.post(PORTED_SERVER_URL, files=files)
10
 
11
  if response.status_code == 200:
12
  apk_url = response.json().get("apk_url", None)
13
  if apk_url:
14
+ return apk_url, gr.update(visible=True) # Show the button
15
+ return "❌ Error converting EXE to APK.", gr.update(visible=False)
16
 
17
  with gr.Blocks() as app:
18
  gr.Markdown("## EXE to APK Converter")
19
 
20
+ upload_button = gr.File(label="Upload EXE File", type="filepath") # ✅ Fixed type
21
  output_text = gr.Textbox(label="Download Link", interactive=False) # Shows the URL
22
  download_button = gr.Button("Download APK", visible=False) # Initially hidden
23
 
24
+ upload_button.change(convert_exe_to_apk, inputs=upload_button, outputs=[output_text, download_button])
 
 
 
 
 
 
25
 
26
  def open_download(url):
27
  return gr.update(value=f"[Click Here to Download]({url})")