sudo-soldier commited on
Commit
b0106bf
·
verified ·
1 Parent(s): 9295187

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -37
app.py CHANGED
@@ -1,45 +1,22 @@
1
- import subprocess
2
  import gradio as gr
3
- import os
4
 
5
- # Function to run Bulldozer via Node.js from Python
6
- def run_bulldozer(pwa_url, app_name, output_dir="output_apk"):
7
  try:
8
- # Ensure the output directory exists
9
- if not os.path.exists(output_dir):
10
- os.makedirs(output_dir)
 
 
11
 
12
- # Run Bulldozer Node.js script using subprocess
13
- result = subprocess.run(
14
- ['node', 'bulldozer.js', pwa_url, app_name, output_dir],
15
- check=True, capture_output=True, text=True
16
- )
17
- return f"APK generated successfully: {os.path.join(output_dir, f'{app_name}.apk')}", os.path.join(output_dir, f'{app_name}.apk')
18
- except subprocess.CalledProcessError as e:
19
- return f"Error generating APK: {e.stderr}", None
20
 
21
- # Create the Gradio interface
22
- def process_url(pwa_url, app_name):
23
- status, apk_path = run_bulldozer(pwa_url, app_name)
24
- return status, apk_path
25
 
26
- with gr.Blocks() as demo:
27
- gr.Markdown("# Convert Website to Android App")
28
-
29
- # User Inputs for the URL and app name
30
- url_input = gr.Textbox(label="Enter Website URL", placeholder="https://example.com")
31
- name_input = gr.Textbox(label="App Name", placeholder="MyWebApp")
32
-
33
- # Output area for status and download link
34
- output_text = gr.Textbox(label="Status")
35
- download_link = gr.File(label="Download APK")
36
-
37
- # Button to trigger the conversion
38
- submit_btn = gr.Button("Generate APK")
39
-
40
- submit_btn.click(process_url, inputs=[url_input, name_input], outputs=[output_text, download_link])
41
-
42
- # Launch Gradio app
43
- demo.launch(share=True)
44
 
45
 
 
 
1
  import gradio as gr
2
+ import requests
3
 
4
+ # Define a function that processes the URL
5
+ def process_url(url):
6
  try:
7
+
8
+ response = requests.get(url)
9
+ return response.status_code, response.text[:500]
10
+ except Exception as e:
11
+ return str(e)
12
 
13
+ # Create a Gradio Interface
14
+ iface = gr.Interface(fn=process_url,
15
+ inputs=gr.Textbox(label="Enter URL"),
16
+ outputs=["text", "text"],
17
+ live=True)
 
 
 
18
 
19
+ iface.launch()
 
 
 
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22