pragnakalp commited on
Commit
709e988
1 Parent(s): 24e2d0b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -21
app.py CHANGED
@@ -49,7 +49,7 @@ Entities_Found =[]
49
  Entity_Types = []
50
  k = 0
51
  def get_device_ip_address():
52
- print('get IP ......................')
53
  if os.name == "nt":
54
  result = "Running on Windows"
55
  hostname = socket.gethostname()
@@ -63,31 +63,30 @@ def get_device_ip_address():
63
  ip_address = s.getsockname()[0]
64
  gateway = gw[2]
65
  host = socket.gethostname()
66
- print("ip_address======>>",ip_address)
67
  return ip_address
68
  else:
69
  result['id'] = os.name + " not supported yet."
70
  print(result)
71
  return result
72
 
73
- def get_location(ip_addr):
74
- print('get location ......................')
75
- ip=ip_addr
76
- # ip=str(request.remote_addr)
77
- req_data={
78
- "ip":ip,
79
- "token":"pkml123"
80
- }
81
- url = "https://demos.pragnakalp.com/get-ip-location"
82
 
83
- # req_data=json.dumps(req_data)
84
- # print("req_data",req_data)
85
- headers = {'Content-Type': 'application/json'}
86
 
87
- response = requests.request("POST", url, headers=headers, data=json.dumps(req_data))
88
- response = response.json()
89
- print("response======>>",response)
90
- return response
91
 
92
  def generate_emotion(article):
93
  text = "Input sentence: "
@@ -118,9 +117,9 @@ def save_data_and_sendmail(article,output):
118
  try:
119
  ip_address = ''
120
  ip_address = get_device_ip_address()
121
- location = get_location(ip_address)
122
 
123
- add_csv = [article,output,ip_address,location]
124
  with open(DATA_FILE, "a") as f:
125
  writer = csv.writer(f)
126
  # write the data
@@ -134,7 +133,7 @@ def save_data_and_sendmail(article,output):
134
  # x = requests.post(url, json = myobj)
135
 
136
  url = 'https://pragnakalpdev33.pythonanywhere.com/HF_space_bert_base_ner'
137
- myobj = {'article': article,'gen_text':output,'ip_addr':ip_address,'loc':location}
138
  x = requests.post(url, json = myobj)
139
 
140
  return "Successfully save data"
 
49
  Entity_Types = []
50
  k = 0
51
  def get_device_ip_address():
52
+
53
  if os.name == "nt":
54
  result = "Running on Windows"
55
  hostname = socket.gethostname()
 
63
  ip_address = s.getsockname()[0]
64
  gateway = gw[2]
65
  host = socket.gethostname()
66
+ print(result)
67
  return ip_address
68
  else:
69
  result['id'] = os.name + " not supported yet."
70
  print(result)
71
  return result
72
 
73
+ # def get_location(ip_addr):
74
+ # ip=ip_addr
75
+ # # ip=str(request.remote_addr)
76
+ # req_data={
77
+ # "ip":ip,
78
+ # "token":"pkml123"
79
+ # }
80
+ # url = "https://demos.pragnakalp.com/get-ip-location"
 
81
 
82
+ # # req_data=json.dumps(req_data)
83
+ # # print("req_data",req_data)
84
+ # headers = {'Content-Type': 'application/json'}
85
 
86
+ # response = requests.request("POST", url, headers=headers, data=json.dumps(req_data))
87
+ # response = response.json()
88
+ # print("response======>>",response)
89
+ # return response
90
 
91
  def generate_emotion(article):
92
  text = "Input sentence: "
 
117
  try:
118
  ip_address = ''
119
  ip_address = get_device_ip_address()
120
+ # location = get_location(ip_address)
121
 
122
+ add_csv = [article,output,ip_address]
123
  with open(DATA_FILE, "a") as f:
124
  writer = csv.writer(f)
125
  # write the data
 
133
  # x = requests.post(url, json = myobj)
134
 
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)
138
 
139
  return "Successfully save data"