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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -22
app.py CHANGED
@@ -1,34 +1,36 @@
1
  import gradio as gr
2
  import requests
3
 
4
- # Ported server URL (your VPS address)
5
- PORTED_SERVER_URL = "http://192.168.1.100:5000/upload" # Use the new VPS IP
6
 
7
  def convert_exe_to_apk(file):
8
- # Send the EXE to the ported server for conversion
9
  files = {"file": file}
10
  response = requests.post(PORTED_SERVER_URL, files=files)
11
 
12
  if response.status_code == 200:
13
- # Extract the APK download link from the server's response
14
- apk_url = response.json().get("apk_url", "Error: No link returned")
15
-
16
- # Return the download URL for Gradio
17
- return apk_url
18
- else:
19
- return "❌ Error converting EXE to APK."
20
-
21
- # Gradio Interface
22
  with gr.Blocks() as app:
23
- gr.Markdown("## EXE to APK Converter (Using Ported Server)")
24
-
25
- # Upload Button
26
- upload_button = gr.UploadButton("Upload EXE File", file_types=[".exe"])
27
-
28
- # Download button (used to show the APK download link)
29
- download_button = gr.Button("Download APK")
30
-
31
- # Action: When EXE is uploaded, the download button is shown with the link
32
- download_button.click(convert_exe_to_apk, inputs=upload_button, outputs=download_button)
 
 
 
 
 
 
 
 
33
 
34
  app.launch()
 
1
  import gradio as gr
2
  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})")
33
+
34
+ download_button.click(open_download, inputs=output_text, outputs=output_text)
35
 
36
  app.launch()