24 lines
No EOL
690 B
Python
24 lines
No EOL
690 B
Python
import time
|
|
import requests
|
|
from threading import Thread
|
|
|
|
class ApiHandler:
|
|
def identify_btclock(self, address):
|
|
self.make_api_call(address, "api/identify")
|
|
return
|
|
|
|
def check_fs_hash(self, address):
|
|
ret = self.run_api_call(address, "fs_hash.txt")
|
|
return ret
|
|
|
|
def make_api_call(self, address, path):
|
|
thread = Thread(target=self.run_api_call, args=(address,path))
|
|
thread.start()
|
|
|
|
def run_api_call(self, address, path):
|
|
try:
|
|
url = f"http://{address}/{path}"
|
|
response = requests.get(url)
|
|
return response.text
|
|
except requests.RequestException as e:
|
|
print("error") |