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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -18
app.py CHANGED
@@ -59,23 +59,23 @@ def get_device_ip_address():
59
  print(result)
60
  return result
61
 
62
- def get_location(ip_addr):
63
- ip=ip_addr
64
- # ip=str(request.remote_addr)
65
- req_data={
66
- "ip":ip,
67
- "token":"pkml123"
68
- }
69
- url = "https://demos.pragnakalp.com/get-ip-location"
70
 
71
- # req_data=json.dumps(req_data)
72
- # print("req_data",req_data)
73
- headers = {'Content-Type': 'application/json'}
74
 
75
- response = requests.request("POST", url, headers=headers, data=json.dumps(req_data))
76
- response = response.json()
77
- print("response======>>",response)
78
- return response
79
 
80
  def generate_questions(article,num_que):
81
  result = ''
@@ -104,9 +104,9 @@ def save_data_and_sendmail(article,generated_questions,num_que,result):
104
  try:
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:
112
  writer = csv.writer(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':ip_address,'loc':location}
121
  x = requests.post(url, json = myobj)
122
  print("myobj^^^^^",myobj)
123
  # with open(DATA_FILE, "r") as file:
 
59
  print(result)
60
  return result
61
 
62
+ # def get_location(ip_addr):
63
+ # ip=ip_addr
64
+ # # ip=str(request.remote_addr)
65
+ # req_data={
66
+ # "ip":ip,
67
+ # "token":"pkml123"
68
+ # }
69
+ # url = "https://demos.pragnakalp.com/get-ip-location"
70
 
71
+ # # req_data=json.dumps(req_data)
72
+ # # print("req_data",req_data)
73
+ # headers = {'Content-Type': 'application/json'}
74
 
75
+ # response = requests.request("POST", url, headers=headers, data=json.dumps(req_data))
76
+ # response = response.json()
77
+ # print("response======>>",response)
78
+ # return response
79
 
80
  def generate_questions(article,num_que):
81
  result = ''
 
104
  try:
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]
110
  print("data^^^^^",add_csv)
111
  with open(DATA_FILE, "a") as f:
112
  writer = csv.writer(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}
121
  x = requests.post(url, json = myobj)
122
  print("myobj^^^^^",myobj)
123
  # with open(DATA_FILE, "r") as file: