Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -151,6 +151,7 @@ with app_tab:
|
|
151 |
|
152 |
with register_tab:
|
153 |
upload_mode = st.radio("Choose Method", ["π€ Upload Image", "π· Take Photo"])
|
|
|
154 |
if upload_mode == "π€ Upload Image":
|
155 |
upload = st.file_uploader("Upload Student Image with plain background(.jpg)", type="jpg")
|
156 |
if upload:
|
@@ -169,8 +170,28 @@ with register_tab:
|
|
169 |
if st.button("Register"):
|
170 |
if not (rno and sname and sclass):
|
171 |
st.warning("Fill all details.")
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
151 |
|
152 |
with register_tab:
|
153 |
upload_mode = st.radio("Choose Method", ["π€ Upload Image", "π· Take Photo"])
|
154 |
+
image_pil = None
|
155 |
if upload_mode == "π€ Upload Image":
|
156 |
upload = st.file_uploader("Upload Student Image with plain background(.jpg)", type="jpg")
|
157 |
if upload:
|
|
|
170 |
if st.button("Register"):
|
171 |
if not (rno and sname and sclass):
|
172 |
st.warning("Fill all details.")
|
173 |
+
# Save locally in employees folder
|
174 |
+
local_path = os.path.join("employees", f"{sname}.jpg")
|
175 |
+
image_pil.save(local_path)
|
176 |
+
|
177 |
+
# Convert image to base64 for sending to Glitch
|
178 |
+
buffered = BytesIO()
|
179 |
+
image_pil.save(buffered, format="JPEG")
|
180 |
+
img_str = base64.b64encode(buffered.getvalue()).decode()
|
181 |
+
|
182 |
+
# Prepare data for POST request
|
183 |
+
glitch_url = "https://your-glitch-app.glitch.me/register" # Replace this
|
184 |
+
data = {
|
185 |
+
"rno": rno,
|
186 |
+
"sname": sname,
|
187 |
+
"sclass": sclass,
|
188 |
+
"image_base64": img_str,
|
189 |
+
}
|
190 |
+
|
191 |
+
response = requests.post(glitch_url, json=data)
|
192 |
+
result = response.json()
|
193 |
+
|
194 |
+
if result["status"] == "success":
|
195 |
+
st.success(result["message"])
|
196 |
+
else:
|
197 |
+
st.error(result["message"])
|