Sanjayraju30 commited on
Commit
1f34a95
Β·
verified Β·
1 Parent(s): 41933ea

Update src/streamlit_app.py

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +19 -4
src/streamlit_app.py CHANGED
@@ -2,6 +2,7 @@ import streamlit as st
2
  from PIL import Image
3
  from ocr_engine import extract_weight_from_image
4
  import urllib.parse
 
5
 
6
  st.set_page_config(page_title="βš–οΈ Auto Weight Logger", layout="centered")
7
  st.title("βš–οΈ Auto Weight Logger")
@@ -29,11 +30,24 @@ if img_data:
29
  st.experimental_rerun()
30
  st.stop()
31
 
32
- st.success(f"βœ… Detected Weight: {weight} g (Confidence: {int(confidence)}%)")
33
-
34
  device_id = "BAL-001"
35
- image_url = ""
36
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  encoded_weight = urllib.parse.quote(str(weight))
38
  encoded_device = urllib.parse.quote(device_id)
39
  encoded_image_url = urllib.parse.quote(image_url)
@@ -43,5 +57,6 @@ if img_data:
43
  f"weight_logger_page?WeightInput={encoded_weight}&DeviceID={encoded_device}&ImageURL={encoded_image_url}"
44
  )
45
 
 
46
  st.markdown("### πŸ“€ Send to Salesforce")
47
  st.markdown(f"[βœ… Click here to confirm and log in Salesforce]({salesforce_url})", unsafe_allow_html=True)
 
2
  from PIL import Image
3
  from ocr_engine import extract_weight_from_image
4
  import urllib.parse
5
+ from datetime import datetime
6
 
7
  st.set_page_config(page_title="βš–οΈ Auto Weight Logger", layout="centered")
8
  st.title("βš–οΈ Auto Weight Logger")
 
30
  st.experimental_rerun()
31
  st.stop()
32
 
33
+ # βœ… Prepare data for preview and URL
 
34
  device_id = "BAL-001"
35
+ image_url = "" # optional - add later if you host the image
36
+ captured_at = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
37
+ status = "Pending Submission"
38
+
39
+ # βœ… Show full preview
40
+ st.markdown("### πŸ“‹ Record Preview (before sending to Salesforce)")
41
+ st.write({
42
+ "Auto Number": "Will be generated in Salesforce",
43
+ "Captured Weight": f"{weight} g",
44
+ "Captured At": captured_at,
45
+ "Snapshot Image": "Attached" if image_url else "Not available",
46
+ "Device ID": device_id,
47
+ "Status": status
48
+ })
49
+
50
+ # βœ… Encode for Salesforce
51
  encoded_weight = urllib.parse.quote(str(weight))
52
  encoded_device = urllib.parse.quote(device_id)
53
  encoded_image_url = urllib.parse.quote(image_url)
 
57
  f"weight_logger_page?WeightInput={encoded_weight}&DeviceID={encoded_device}&ImageURL={encoded_image_url}"
58
  )
59
 
60
+ # βœ… Show Salesforce link
61
  st.markdown("### πŸ“€ Send to Salesforce")
62
  st.markdown(f"[βœ… Click here to confirm and log in Salesforce]({salesforce_url})", unsafe_allow_html=True)