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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -15
app.py CHANGED
@@ -4,28 +4,27 @@ import requests
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})")
28
-
29
- download_button.click(open_download, inputs=output_text, outputs=output_text)
30
-
31
  app.launch()
 
4
  PORTED_SERVER_URL = "http://192.168.1.100:5000/upload"
5
 
6
  def convert_exe_to_apk(file_path):
7
+ try:
8
+ with open(file_path, "rb") as f:
9
+ files = {"file": f}
10
+ response = requests.post(PORTED_SERVER_URL, files=files)
11
+
12
+ if response.status_code == 200:
13
+ apk_url = response.json().get("apk_url", None)
14
+ if apk_url:
15
+ return apk_url, gr.update(visible=True) # Show the button
16
+ else:
17
+ return f"❌ Server Error: {response.json().get('error', 'Unknown Error')}", gr.update(visible=False)
18
+ except Exception as e:
19
+ return f"❌ Failed to upload: {str(e)}", gr.update(visible=False)
20
 
21
  with gr.Blocks() as app:
22
  gr.Markdown("## EXE to APK Converter")
23
 
24
+ upload_button = gr.File(label="Upload EXE File", type="filepath") # ✅ Corrected type
25
  output_text = gr.Textbox(label="Download Link", interactive=False) # Shows the URL
26
  download_button = gr.Button("Download APK", visible=False) # Initially hidden
27
 
28
  upload_button.change(convert_exe_to_apk, inputs=upload_button, outputs=[output_text, download_button])
29
 
 
 
 
 
 
30
  app.launch()