Spaces:
Sleeping
Sleeping
Update src/streamlit_app.py
Browse files- 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 |
-
|
| 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)
|