Karlsen commited on
Commit
c6e21a1
1 Parent(s): a5bc396

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -20
app.py CHANGED
@@ -1,3 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
2
  import requests
3
  import pandas as pd
@@ -45,34 +89,14 @@ def get_lat_lon(place_name):
45
  st.error(f"Error fetching coordinates for the place. HTTP status code: {response.status_code}")
46
  return None, None
47
 
48
- # Function to translate text into English using MyMemory Translation API
49
- def translate_text(text, target_language='en'):
50
- url = "https://api.mymemory.translated.net/get"
51
- params = {
52
- 'q': text,
53
- 'langpair': f'{original_language}|{target_language}'
54
- }
55
- response = requests.get(url, params=params)
56
- if response.status_code == 200:
57
- data = response.json()
58
- return data['responseData']['translatedText']
59
- else:
60
- st.error("Error translating text.")
61
- return text
62
-
63
  # Streamlit app
64
  def main():
65
  st.title("Earthquake Data Lookup")
66
 
67
  # Input field for the place name
68
  place_name = st.sidebar.text_input("Enter City or Country Name", "San Francisco")
69
- original_language = st.sidebar.text_input("Enter the original language code (e.g., 'es' for Spanish)", "en")
70
 
71
  if place_name:
72
- # Translate place name to English if necessary
73
- if original_language != 'en':
74
- place_name = translate_text(place_name, 'en')
75
-
76
  latitude, longitude = get_lat_lon(place_name)
77
 
78
  if latitude is not None and longitude is not None:
@@ -109,3 +133,4 @@ def main():
109
 
110
  if __name__ == "__main__":
111
  main()
 
 
1
+ Hugging Face's logo
2
+ Hugging Face
3
+ Search models, datasets, users...
4
+ Models
5
+ Datasets
6
+ Spaces
7
+ Posts
8
+ Docs
9
+ Solutions
10
+ Pricing
11
+
12
+
13
+
14
+ Spaces:
15
+
16
+ Karlsen
17
+ /
18
+ Earthquake_app
19
+
20
+
21
+ like
22
+ 0
23
+
24
+ Logs
25
+ App
26
+ Files
27
+ Community
28
+ Settings
29
+ Earthquake_app
30
+ /
31
+ app.py
32
+
33
+ Karlsen's picture
34
+ Karlsen
35
+ Update app.py
36
+ 611148e
37
+ VERIFIED
38
+ less than a minute ago
39
+ raw
40
+ history
41
+ blame
42
+ edit
43
+ delete
44
+ 3.83 kB
45
  import streamlit as st
46
  import requests
47
  import pandas as pd
 
89
  st.error(f"Error fetching coordinates for the place. HTTP status code: {response.status_code}")
90
  return None, None
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  # Streamlit app
93
  def main():
94
  st.title("Earthquake Data Lookup")
95
 
96
  # Input field for the place name
97
  place_name = st.sidebar.text_input("Enter City or Country Name", "San Francisco")
 
98
 
99
  if place_name:
 
 
 
 
100
  latitude, longitude = get_lat_lon(place_name)
101
 
102
  if latitude is not None and longitude is not None:
 
133
 
134
  if __name__ == "__main__":
135
  main()
136
+