pragnakalp commited on
Commit
e1e26dd
1 Parent(s): abb6ec0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +17 -16
app.py CHANGED
@@ -68,23 +68,23 @@ def get_device_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 generate_emotion(article):
90
  text = "Input sentence: "
@@ -130,7 +130,8 @@ 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
-
 
134
  url = 'https://pragnakalpdev33.pythonanywhere.com/HF_space_bert_base_ner'
135
  myobj = {'article': article,'gen_text':output,'ip_addr':ip_address}
136
  x = requests.post(url, json = myobj)
 
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 generate_emotion(article):
90
  text = "Input sentence: "
 
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(ip_address)
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}
137
  x = requests.post(url, json = myobj)