pragnakalp commited on
Commit
1a1f9ff
·
1 Parent(s): 662387f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -50,7 +50,7 @@ def get_device_ip_address():
50
  gw = os.popen("ip -4 route show default").read().split()
51
  s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
52
  s.connect((gw[2], 0))
53
- ipaddr = s.getsockname()[0]
54
  gateway = gw[2]
55
  host = socket.gethostname()
56
  return ip_address
@@ -105,7 +105,7 @@ def save_data_and_sendmail(article,generated_questions,num_que,result):
105
  ip_address = ''
106
  ip_address = get_device_ip_address()
107
  location = get_location(ip_address)
108
-
109
  add_csv = [article, generated_questions, num_que, ip_address, location]
110
  print("data^^^^^",add_csv)
111
  with open(DATA_FILE, "a") as f:
@@ -117,7 +117,7 @@ def save_data_and_sendmail(article,generated_questions,num_que,result):
117
 
118
  url = 'https://pragnakalpdev35.pythonanywhere.com/HF_space_que_gen'
119
  # url = 'http://pragnakalpdev33.pythonanywhere.com/HF_space_question_generator'
120
- myobj = {'article': article,'total_que': num_que,'gen_que':result,'ip_addr':hostname.get("ip_addr",""),'host':hostname.get("host","")}
121
  x = requests.post(url, json = myobj)
122
  print("myobj^^^^^",myobj)
123
  # with open(DATA_FILE, "r") as file:
 
50
  gw = os.popen("ip -4 route show default").read().split()
51
  s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
52
  s.connect((gw[2], 0))
53
+ ip_address = s.getsockname()[0]
54
  gateway = gw[2]
55
  host = socket.gethostname()
56
  return ip_address
 
105
  ip_address = ''
106
  ip_address = get_device_ip_address()
107
  location = get_location(ip_address)
108
+ print(location)
109
  add_csv = [article, generated_questions, num_que, ip_address, location]
110
  print("data^^^^^",add_csv)
111
  with open(DATA_FILE, "a") as f:
 
117
 
118
  url = 'https://pragnakalpdev35.pythonanywhere.com/HF_space_que_gen'
119
  # url = 'http://pragnakalpdev33.pythonanywhere.com/HF_space_question_generator'
120
+ myobj = {'article': article,'total_que': num_que,'gen_que':result,'ip_addr':ip_address,'loc':location}
121
  x = requests.post(url, json = myobj)
122
  print("myobj^^^^^",myobj)
123
  # with open(DATA_FILE, "r") as file: