Update app.py
Browse files
app.py
CHANGED
|
@@ -269,27 +269,28 @@ def generate_from_pdf(pdf_file):
|
|
| 269 |
raise e
|
| 270 |
raise Exception("β Failed after 3 retries due to Gemini API quota limits.")
|
| 271 |
|
|
|
|
|
|
|
|
|
|
| 272 |
# -----------------------
|
| 273 |
# Gradio UI
|
| 274 |
# -----------------------
|
| 275 |
with gr.Blocks() as demo:
|
| 276 |
-
gr.Markdown("## π§©
|
| 277 |
pdf_input = gr.File(label="π Upload Business Requirement PDF", file_types=[".pdf"])
|
| 278 |
-
generate_btn = gr.Button("π Generate Interactive
|
| 279 |
-
|
|
|
|
| 280 |
|
| 281 |
-
def
|
| 282 |
-
|
| 283 |
-
app_title, screens = analyze_business_pdf(pdf_file)
|
| 284 |
-
_ = generate_mockups(app_title, screens)
|
| 285 |
html_files = [f for f in os.listdir('.') if f.startswith('mockup_interactive_') and f.endswith('.html')]
|
| 286 |
if html_files:
|
| 287 |
last_html = sorted(html_files, key=os.path.getmtime)[-1]
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
return "<p style='color:red;'>Failed to generate interactive mockup.</p>"
|
| 292 |
|
| 293 |
-
generate_btn.click(fn=
|
| 294 |
|
| 295 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 269 |
raise e
|
| 270 |
raise Exception("β Failed after 3 retries due to Gemini API quota limits.")
|
| 271 |
|
| 272 |
+
# -----------------------
|
| 273 |
+
# Gradio UI
|
| 274 |
+
# -----------------------
|
| 275 |
# -----------------------
|
| 276 |
# Gradio UI
|
| 277 |
# -----------------------
|
| 278 |
with gr.Blocks() as demo:
|
| 279 |
+
gr.Markdown("## π§© Intelligent PowerApps Mockup Generator (Interactive Prototype Mode)")
|
| 280 |
pdf_input = gr.File(label="π Upload Business Requirement PDF", file_types=[".pdf"])
|
| 281 |
+
generate_btn = gr.Button("π Generate Interactive App")
|
| 282 |
+
gallery_output = gr.Gallery(label="Generated Preview", show_label=True, columns=2)
|
| 283 |
+
html_link = gr.HTML()
|
| 284 |
|
| 285 |
+
def generate_and_return_link(pdf_file):
|
| 286 |
+
images = generate_from_pdf(pdf_file)
|
|
|
|
|
|
|
| 287 |
html_files = [f for f in os.listdir('.') if f.startswith('mockup_interactive_') and f.endswith('.html')]
|
| 288 |
if html_files:
|
| 289 |
last_html = sorted(html_files, key=os.path.getmtime)[-1]
|
| 290 |
+
html_url = f"<a href='file://{os.path.abspath(last_html)}' target='_blank' style='font-size:16px;color:#0078d4;text-decoration:none;'>π Open Interactive Prototype</a>"
|
| 291 |
+
return images, html_url
|
| 292 |
+
return images, "<p style='color:red;'>No HTML file found.</p>"
|
|
|
|
| 293 |
|
| 294 |
+
generate_btn.click(fn=generate_and_return_link, inputs=pdf_input, outputs=[gallery_output, html_link])
|
| 295 |
|
| 296 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|