Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,45 +1,22 @@
|
|
| 1 |
-
import subprocess
|
| 2 |
import gradio as gr
|
| 3 |
-
import
|
| 4 |
|
| 5 |
-
#
|
| 6 |
-
def
|
| 7 |
try:
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 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 |
-
|
| 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 |
|