nikshep01 commited on
Commit
f975291
·
verified ·
1 Parent(s): c6f5943

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -0
app.py CHANGED
@@ -33,6 +33,40 @@ encodeListknown = [face_recognition.face_encodings(img)[0] for img in Images]
33
  # camera to take photo of user in question
34
  file_name = st.camera_input("Upload image")
35
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  def add_attendance(names):
37
  url = "https://ai-ml-project.glitch.me/adduserdata1" # Change this URL to your Glitch endpoint
38
  success_count = 0
 
33
  # camera to take photo of user in question
34
  file_name = st.camera_input("Upload image")
35
 
36
+ geolocation_js = """
37
+ <script>
38
+ function getLocation() {
39
+ if (navigator.geolocation) {
40
+ navigator.geolocation.getCurrentPosition(sendLocation);
41
+ } else {
42
+ alert("Geolocation is not supported by this browser.");
43
+ }
44
+ }
45
+
46
+ function sendLocation(position) {
47
+ var latitude = position.coords.latitude;
48
+ var longitude = position.coords.longitude;
49
+ Streamlit.setComponentValue({"latitude": latitude, "longitude": longitude});
50
+ }
51
+ </script>
52
+ """
53
+
54
+ # Display the JavaScript code
55
+ st.write(geolocation_js, unsafe_allow_html=True)
56
+
57
+ # Run JavaScript code to access geolocation when button is clicked
58
+ button_clicked = st.button("Get Location")
59
+ if button_clicked:
60
+ st.write("<script>getLocation()</script>", unsafe_allow_html=True)
61
+
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