SebastianAndreu commited on
Commit
578d6cc
·
verified ·
1 Parent(s): 9d51c94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -25
app.py CHANGED
@@ -1268,8 +1268,7 @@ with gr.Blocks(title="Makerspace Inventory System", css=CUSTOM_CSS) as demo:
1268
  height=400
1269
  )
1270
 
1271
- if EXAMPLE_CHECKOUT_IMAGE:
1272
- load_example_checkout_btn = gr.Button("📸 Load Example", size="sm", variant="secondary", scale=0)
1273
 
1274
  with gr.Column(scale=1):
1275
  gr.Markdown("""
@@ -1364,8 +1363,7 @@ with gr.Blocks(title="Makerspace Inventory System", css=CUSTOM_CSS) as demo:
1364
 
1365
  receipt_file = gr.File(label="Upload Receipt (PDF or Image)", file_types=[".pdf", ".png", ".jpg", ".jpeg"])
1366
 
1367
- if EXAMPLE_RECEIPT_PDF:
1368
- load_example_receipt_btn = gr.Button("📄 Load Example", size="sm", variant="secondary", scale=0)
1369
 
1370
  receipt_status = gr.Markdown("")
1371
 
@@ -1740,29 +1738,32 @@ with gr.Blocks(title="Makerspace Inventory System", css=CUSTOM_CSS) as demo:
1740
  )
1741
 
1742
  # EXAMPLE INPUTS
1743
- if EXAMPLE_CHECKOUT_IMAGE:
1744
- def load_checkout_example():
1745
- try:
1746
  return Image.open(EXAMPLE_CHECKOUT_IMAGE)
1747
- except:
1748
- return None
1749
-
1750
- load_example_checkout_btn.click(
1751
- fn=load_checkout_example,
1752
- outputs=[checkout_image]
1753
- )
 
1754
 
1755
- if EXAMPLE_RECEIPT_PDF:
1756
- def load_receipt_example():
1757
- try:
1758
  return EXAMPLE_RECEIPT_PDF
1759
- except:
1760
- return None
1761
-
1762
- load_example_receipt_btn.click(
1763
- fn=load_receipt_example,
1764
- outputs=[receipt_file]
1765
- )
 
1766
 
1767
  if __name__ == "__main__":
1768
- demo.launch()
 
 
1268
  height=400
1269
  )
1270
 
1271
+ load_example_checkout_btn = gr.Button("📸 Load Example", size="sm", variant="secondary", scale=0, visible=EXAMPLE_CHECKOUT_IMAGE is not None)
 
1272
 
1273
  with gr.Column(scale=1):
1274
  gr.Markdown("""
 
1363
 
1364
  receipt_file = gr.File(label="Upload Receipt (PDF or Image)", file_types=[".pdf", ".png", ".jpg", ".jpeg"])
1365
 
1366
+ load_example_receipt_btn = gr.Button("📄 Load Example", size="sm", variant="secondary", scale=0, visible=EXAMPLE_RECEIPT_PDF is not None)
 
1367
 
1368
  receipt_status = gr.Markdown("")
1369
 
 
1738
  )
1739
 
1740
  # EXAMPLE INPUTS
1741
+ def load_checkout_example():
1742
+ try:
1743
+ if EXAMPLE_CHECKOUT_IMAGE:
1744
  return Image.open(EXAMPLE_CHECKOUT_IMAGE)
1745
+ except:
1746
+ pass
1747
+ return None
1748
+
1749
+ load_example_checkout_btn.click(
1750
+ fn=load_checkout_example,
1751
+ outputs=[checkout_image]
1752
+ )
1753
 
1754
+ def load_receipt_example():
1755
+ try:
1756
+ if EXAMPLE_RECEIPT_PDF:
1757
  return EXAMPLE_RECEIPT_PDF
1758
+ except:
1759
+ pass
1760
+ return None
1761
+
1762
+ load_example_receipt_btn.click(
1763
+ fn=load_receipt_example,
1764
+ outputs=[receipt_file]
1765
+ )
1766
 
1767
  if __name__ == "__main__":
1768
+ demo.queue()
1769
+ demo.launch()