Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -36,17 +36,22 @@ file_name = st.camera_input("Upload image")
|
|
36 |
geolocation_js = """
|
37 |
<script>
|
38 |
function getLocation() {
|
|
|
39 |
if (navigator.geolocation) {
|
40 |
-
|
|
|
41 |
} else {
|
42 |
alert("Geolocation is not supported by this browser.");
|
43 |
}
|
44 |
}
|
45 |
|
46 |
function sendLocation(position) {
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
50 |
}
|
51 |
</script>
|
52 |
"""
|
@@ -62,11 +67,12 @@ if button_clicked:
|
|
62 |
# Receive latitude and longitude from JavaScript
|
63 |
latitude_received = st.session_state.get("latitude")
|
64 |
longitude_received = st.session_state.get("longitude")
|
65 |
-
|
66 |
# Display latitude and longitude
|
67 |
if latitude_received is not None and longitude_received is not None:
|
68 |
st.write(f"Latitude: {latitude_received}, Longitude: {longitude_received}")
|
69 |
-
|
|
|
70 |
def add_attendance(names):
|
71 |
url = "https://ai-ml-project.glitch.me/adduserdata1" # Change this URL to your Glitch endpoint
|
72 |
success_count = 0
|
|
|
36 |
geolocation_js = """
|
37 |
<script>
|
38 |
function getLocation() {
|
39 |
+
console.log("Attempting to get location...");
|
40 |
if (navigator.geolocation) {
|
41 |
+
console.log("Geolocation supported, getting current position...");
|
42 |
+
navigator.geolocation.getCurrentPosition(sendLocation, handleLocationError);
|
43 |
} else {
|
44 |
alert("Geolocation is not supported by this browser.");
|
45 |
}
|
46 |
}
|
47 |
|
48 |
function sendLocation(position) {
|
49 |
+
console.log("Location obtained successfully:", position.coords.latitude, position.coords.longitude);
|
50 |
+
Streamlit.setComponentValue({"latitude": position.coords.latitude, "longitude": position.coords.longitude});
|
51 |
+
}
|
52 |
+
|
53 |
+
function handleLocationError(error) {
|
54 |
+
console.error("Error getting location:", error.message);
|
55 |
}
|
56 |
</script>
|
57 |
"""
|
|
|
67 |
# Receive latitude and longitude from JavaScript
|
68 |
latitude_received = st.session_state.get("latitude")
|
69 |
longitude_received = st.session_state.get("longitude")
|
70 |
+
|
71 |
# Display latitude and longitude
|
72 |
if latitude_received is not None and longitude_received is not None:
|
73 |
st.write(f"Latitude: {latitude_received}, Longitude: {longitude_received}")
|
74 |
+
else:
|
75 |
+
st.write("Latitude and longitude not yet obtained.")
|
76 |
def add_attendance(names):
|
77 |
url = "https://ai-ml-project.glitch.me/adduserdata1" # Change this URL to your Glitch endpoint
|
78 |
success_count = 0
|