dina1 commited on
Commit
d94a6bf
Β·
verified Β·
1 Parent(s): e2ad3aa

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -12
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("## 🧩 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)
 
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)