Rasleen commited on
Commit
6c9e52a
Β·
verified Β·
1 Parent(s): 5eaad66

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -5
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
- elif roll_exists(rno):
173
- st.error("Student with this roll_no registered already.")
174
- else:
175
- register_student(rno, sname, sclass, image_pil)
176
- st.success("Student registered successfully.")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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"])