Spaces:
Running
Running
pragnakalp
commited on
Commit
•
b011ecc
1
Parent(s):
e1e26dd
Update app.py
Browse files
app.py
CHANGED
@@ -68,23 +68,39 @@ def get_device_ip_address():
|
|
68 |
print(result)
|
69 |
return result
|
70 |
|
71 |
-
def get_location(ip_addr):
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
|
|
|
|
|
|
|
|
79 |
|
80 |
-
|
81 |
-
|
82 |
-
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
|
89 |
def generate_emotion(article):
|
90 |
text = "Input sentence: "
|
@@ -130,7 +146,7 @@ def save_data_and_sendmail(article,output):
|
|
130 |
# # url = 'http://pragnakalpdev33.pythonanywhere.com/HF_space_question_generator'
|
131 |
# myobj = {'article': article,'total_que': num_que,'gen_que':result,'ip_addr':hostname.get("ip_addr",""),'host':hostname.get("host","")}
|
132 |
# x = requests.post(url, json = myobj)
|
133 |
-
location = get_location(
|
134 |
print(location)
|
135 |
url = 'https://pragnakalpdev33.pythonanywhere.com/HF_space_bert_base_ner'
|
136 |
myobj = {'article': article,'gen_text':output,'ip_addr':ip_address}
|
|
|
68 |
print(result)
|
69 |
return result
|
70 |
|
71 |
+
# def get_location(ip_addr):
|
72 |
+
# ip=ip_addr
|
73 |
+
# # ip=str(request.remote_addr)
|
74 |
+
# req_data={
|
75 |
+
# "ip":ip,
|
76 |
+
# "token":"pkml123"
|
77 |
+
# }
|
78 |
+
# url = "https://demos.pragnakalp.com/get-ip-location"
|
79 |
+
|
80 |
+
# # req_data=json.dumps(req_data)
|
81 |
+
# # print("req_data",req_data)
|
82 |
+
# headers = {'Content-Type': 'application/json'}
|
83 |
|
84 |
+
# response = requests.request("POST", url, headers=headers, data=json.dumps(req_data))
|
85 |
+
# response = response.json()
|
86 |
+
# print("response======>>",response)
|
87 |
+
# return response
|
88 |
+
|
89 |
+
def get_ip():
|
90 |
+
response = requests.get('https://api64.ipify.org?format=json').json()
|
91 |
+
return response["ip"]
|
92 |
|
93 |
+
|
94 |
+
def get_location():
|
95 |
+
ip_address = get_ip()
|
96 |
+
response = requests.get(f'https://ipapi.co/{ip_address}/json/').json()
|
97 |
+
location_data = {
|
98 |
+
"ip": ip_address,
|
99 |
+
"city": response.get("city"),
|
100 |
+
"region": response.get("region"),
|
101 |
+
"country": response.get("country_name")
|
102 |
+
}
|
103 |
+
return location_data
|
104 |
|
105 |
def generate_emotion(article):
|
106 |
text = "Input sentence: "
|
|
|
146 |
# # url = 'http://pragnakalpdev33.pythonanywhere.com/HF_space_question_generator'
|
147 |
# myobj = {'article': article,'total_que': num_que,'gen_que':result,'ip_addr':hostname.get("ip_addr",""),'host':hostname.get("host","")}
|
148 |
# x = requests.post(url, json = myobj)
|
149 |
+
location = get_location()
|
150 |
print(location)
|
151 |
url = 'https://pragnakalpdev33.pythonanywhere.com/HF_space_bert_base_ner'
|
152 |
myobj = {'article': article,'gen_text':output,'ip_addr':ip_address}
|