pragnakalp commited on
Commit
b881409
·
1 Parent(s): 7efe916

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -2
app.py CHANGED
@@ -38,7 +38,7 @@ repo = Repository(
38
  local_dir="que_gen_logs", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
39
  )
40
 
41
- def get_device_ip_address():
42
  result = {}
43
  if os.name == "nt":
44
  result = "Running on Windows"
@@ -95,8 +95,30 @@ def save_data_and_sendmail(article,generated_questions,num_que,result):
95
  generated_questions1 = generated_questions
96
  num_que1 = num_que
97
  result1 = result
 
98
  print("********",article1,generated_questions1,num_que1,result1)
99
- hostname = get_device_ip_address()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
  print(hostname)
101
  url = 'https://pragnakalpdev35.pythonanywhere.com/HF_space_que_gen'
102
  # url = 'http://pragnakalpdev33.pythonanywhere.com/HF_space_question_generator'
 
38
  local_dir="que_gen_logs", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
39
  )
40
 
41
+ def get_device_ip_address1():
42
  result = {}
43
  if os.name == "nt":
44
  result = "Running on Windows"
 
95
  generated_questions1 = generated_questions
96
  num_que1 = num_que
97
  result1 = result
98
+ result2 = {}
99
  print("********",article1,generated_questions1,num_que1,result1)
100
+ # hostname = get_device_ip_address()
101
+ if os.name == "nt":
102
+ result = "Running on Windows"
103
+ hostname = socket.gethostname()
104
+ ip_address = socket.gethostbyname(hostname)
105
+ result2['ip_addr'] = ip_address
106
+ result2['host'] = hostname
107
+ print(result2)
108
+ elif os.name == "posix":
109
+ gw = os.popen("ip -4 route show default").read().split()
110
+ s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
111
+ s.connect((gw[2], 0))
112
+ ipaddr = s.getsockname()[0]
113
+ gateway = gw[2]
114
+ host = socket.gethostname()
115
+ result2['ip_addr'] = ipaddr
116
+ result2['host'] = host
117
+ print(result2)
118
+ else:
119
+ result2['id'] = os.name + " not supported yet."
120
+ print(result2)
121
+ hostname = result2
122
  print(hostname)
123
  url = 'https://pragnakalpdev35.pythonanywhere.com/HF_space_que_gen'
124
  # url = 'http://pragnakalpdev33.pythonanywhere.com/HF_space_question_generator'