Commit
·
b4ad87b
1
Parent(s):
97eaf7f
Update app.py
Browse files
app.py
CHANGED
@@ -40,43 +40,59 @@ repo = Repository(
|
|
40 |
local_dir="que_gen_logs", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
|
41 |
)
|
42 |
|
43 |
-
def get_device_ip_address():
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
# def get_location(ip_addr):
|
64 |
-
# ip=ip_addr
|
65 |
-
# # ip=str(request.remote_addr)
|
66 |
-
# req_data={
|
67 |
-
# "ip":ip,
|
68 |
-
# "token":"pkml123"
|
69 |
-
# }
|
70 |
-
# url = "https://demos.pragnakalp.com/get-ip-location"
|
71 |
|
72 |
-
|
73 |
-
|
74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
|
81 |
def generate_questions(article,num_que):
|
82 |
result = ''
|
|
|
40 |
local_dir="que_gen_logs", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
|
41 |
)
|
42 |
|
43 |
+
# def get_device_ip_address():
|
44 |
+
# if os.name == "nt":
|
45 |
+
# result = "Running on Windows"
|
46 |
+
# hostname = socket.gethostname()
|
47 |
+
# ip_address = socket.gethostbyname(hostname)
|
48 |
+
# return ip_address
|
49 |
+
# elif os.name == "posix":
|
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 |
+
# print("----->",ip_address)
|
57 |
+
# return ip_address
|
58 |
+
# else:
|
59 |
+
# result['id'] = os.name + " not supported yet."
|
60 |
+
# print(result)
|
61 |
+
# return result
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
+
def getIP():
|
64 |
+
ip_address = ''
|
65 |
+
try:
|
66 |
+
d = str(urlopen('http://checkip.dyndns.com/')
|
67 |
+
.read())
|
68 |
+
|
69 |
+
return r.compile(r'Address: (\d+\.\d+\.\d+\.\d+)').search(d).group(1)
|
70 |
+
except Exception as e:
|
71 |
+
print("Error while getting IP address -->",e)
|
72 |
+
return ip_address
|
73 |
|
74 |
+
def get_location(ip_addr):
|
75 |
+
location = {}
|
76 |
+
try:
|
77 |
+
ip=ip_addr
|
78 |
+
|
79 |
+
req_data={
|
80 |
+
"ip":ip,
|
81 |
+
"token":"pkml123"
|
82 |
+
}
|
83 |
+
url = "https://demos.pragnakalp.com/get-ip-location"
|
84 |
+
|
85 |
+
# req_data=json.dumps(req_data)
|
86 |
+
# print("req_data",req_data)
|
87 |
+
headers = {'Content-Type': 'application/json'}
|
88 |
+
|
89 |
+
response = requests.request("POST", url, headers=headers, data=json.dumps(req_data))
|
90 |
+
response = response.json()
|
91 |
+
print("response======>>",response)
|
92 |
+
return response
|
93 |
+
except Exception as e:
|
94 |
+
print("Error while getting location -->",e)
|
95 |
+
return location
|
96 |
|
97 |
def generate_questions(article,num_que):
|
98 |
result = ''
|