habulaj commited on
Commit
cdc7c5b
·
1 Parent(s): 014a4a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -13,16 +13,20 @@ async def get_location(request: Request):
13
  """
14
  # Obtendo o IP do cliente
15
  client_host = request.client.host
16
-
17
  # Consultando informações de localização
18
  details = handler.getDetails(client_host)
19
- location_data = {
20
- "ip": details.ip,
21
- "city": details.city,
22
- "region": details.region,
23
- "country": details.country,
24
- "latitude": details.latitude,
25
- "longitude": details.longitude,
26
- "organization": details.org
 
 
 
 
 
27
  }
28
- return location_data
 
13
  """
14
  # Obtendo o IP do cliente
15
  client_host = request.client.host
16
+
17
  # Consultando informações de localização
18
  details = handler.getDetails(client_host)
19
+
20
+ # Extraindo informações disponíveis
21
+ location_data = details.all
22
+
23
+ # Retornando as informações como JSON
24
+ return {
25
+ "ip": location_data.get("ip", "Desconhecido"),
26
+ "city": location_data.get("city", "Desconhecida"),
27
+ "region": location_data.get("region", "Desconhecida"),
28
+ "country": location_data.get("country", "Desconhecido"),
29
+ "latitude": location_data.get("latitude", "Desconhecida"),
30
+ "longitude": location_data.get("longitude", "Desconhecida"),
31
+ "organization": location_data.get("org", "Desconhecida")
32
  }