Update app.py
Browse files
app.py
CHANGED
|
@@ -273,11 +273,23 @@ def generate_from_pdf(pdf_file):
|
|
| 273 |
# Gradio UI
|
| 274 |
# -----------------------
|
| 275 |
with gr.Blocks() as demo:
|
| 276 |
-
gr.Markdown("## π§©
|
| 277 |
-
gr.Markdown("Upload a **Business Requirement PDF**. Gemini 2.5 Pro will infer all screens, UI elements, and layouts β then render separate PowerApps-style mockup images for each screen.")
|
| 278 |
pdf_input = gr.File(label="π Upload Business Requirement PDF", file_types=[".pdf"])
|
| 279 |
-
generate_btn = gr.Button("π Generate
|
| 280 |
-
|
| 281 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 282 |
|
| 283 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
| 273 |
# Gradio UI
|
| 274 |
# -----------------------
|
| 275 |
with gr.Blocks() as demo:
|
| 276 |
+
gr.Markdown("## π§© Interactive PowerApps Mockup Viewer")
|
|
|
|
| 277 |
pdf_input = gr.File(label="π Upload Business Requirement PDF", file_types=[".pdf"])
|
| 278 |
+
generate_btn = gr.Button("π Generate Interactive Mockup")
|
| 279 |
+
html_output = gr.HTML()
|
| 280 |
+
|
| 281 |
+
def generate_interactive(pdf_file):
|
| 282 |
+
# Generate the interactive HTML
|
| 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 |
+
with open(last_html, "r", encoding="utf-8") as f:
|
| 289 |
+
html_content = f.read()
|
| 290 |
+
return html_content
|
| 291 |
+
return "<p style='color:red;'>Failed to generate interactive mockup.</p>"
|
| 292 |
+
|
| 293 |
+
generate_btn.click(fn=generate_interactive, inputs=pdf_input, outputs=html_output)
|
| 294 |
|
| 295 |
demo.launch(server_name="0.0.0.0", server_port=7860)
|