Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,22 +35,21 @@ file_name = st.camera_input("Upload image")
|
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
-
def add_attendance(
|
| 39 |
url = "https://ai-ml-project.glitch.me/adduserdata1" # Change this URL to your Glitch endpoint
|
| 40 |
-
success_count = 0
|
| 41 |
-
print(len(names))
|
| 42 |
-
|
| 43 |
data = {'name': name}
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
st.
|
| 52 |
-
|
| 53 |
-
st.
|
|
|
|
|
|
|
| 54 |
|
| 55 |
if file_name is not None:
|
| 56 |
col1, col2 = st.columns(2)
|
|
@@ -83,7 +82,8 @@ if file_name is not None:
|
|
| 83 |
|
| 84 |
# Append recognized name to the list
|
| 85 |
recognized_names.append(name)
|
| 86 |
-
|
|
|
|
| 87 |
# Draw rectangle around the face
|
| 88 |
y1, x2, y2, x1 = faceLoc
|
| 89 |
y1, x2, y2, x1 = (y1 * 4), (x2 * 4), (y2 * 4) ,(x1 * 4)
|
|
|
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
+
def add_attendance(name):
|
| 39 |
url = "https://ai-ml-project.glitch.me/adduserdata1" # Change this URL to your Glitch endpoint
|
|
|
|
|
|
|
|
|
|
| 40 |
data = {'name': name}
|
| 41 |
+
try:
|
| 42 |
+
response = requests.get(url, data=data, timeout=10)
|
| 43 |
+
if response.status_code == 200:
|
| 44 |
+
st.success(f"Attendance marked for {name}")
|
| 45 |
+
else:
|
| 46 |
+
st.warning(f"Failed to mark attendance for {name}. Status code: {response.status_code}")
|
| 47 |
+
except requests.exceptions.ConnectionError:
|
| 48 |
+
st.error(f"Failed to connect to the server for {name}. Please check the server.")
|
| 49 |
+
except requests.exceptions.Timeout:
|
| 50 |
+
st.error(f"Request timed out for {name}.")
|
| 51 |
+
except Exception as e:
|
| 52 |
+
st.error(f"An unexpected error occurred for {name}: {str(e)}")
|
| 53 |
|
| 54 |
if file_name is not None:
|
| 55 |
col1, col2 = st.columns(2)
|
|
|
|
| 82 |
|
| 83 |
# Append recognized name to the list
|
| 84 |
recognized_names.append(name)
|
| 85 |
+
|
| 86 |
+
|
| 87 |
# Draw rectangle around the face
|
| 88 |
y1, x2, y2, x1 = faceLoc
|
| 89 |
y1, x2, y2, x1 = (y1 * 4), (x2 * 4), (y2 * 4) ,(x1 * 4)
|