35 lines
1.3 KiB
Python
35 lines
1.3 KiB
Python
import urllib.request
|
|
import json
|
|
import ssl
|
|
|
|
SUPA_URL = 'http://192.168.1.61:18000'
|
|
SUPA_KEY = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJyb2xlIjoiYW5vbiIsImlzcyI6InN1cGFiYXNlLTEiLCJpYXQiOjE3Njk2NzY0OTgsImV4cCI6MTkyNzM1NjQ5OH0.ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'
|
|
|
|
headers = {
|
|
"apikey": SUPA_KEY,
|
|
"Authorization": f"Bearer {SUPA_KEY}",
|
|
"Content-Type": "application/json"
|
|
}
|
|
|
|
def check_shop(name_part):
|
|
try:
|
|
# Use ilike filter
|
|
url = f"{SUPA_URL}/rest/v1/ml_shops?shop_name=ilike.*{name_part}*&select=*"
|
|
req = urllib.request.Request(url, headers=headers)
|
|
context = ssl._create_unverified_context()
|
|
with urllib.request.urlopen(req, context=context, timeout=5) as response:
|
|
if response.status == 200:
|
|
data = json.loads(response.read().decode())
|
|
print(f"Search for '{name_part}': Found {len(data)} shops")
|
|
for shop in data:
|
|
print(f" - {shop.get('shop_name')} (ID: {shop.get('id')}, Status: {shop.get('status')})")
|
|
else:
|
|
print(f"Error {response.status}")
|
|
except Exception as e:
|
|
print(f"EXCEPTION: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
print("Starting check...")
|
|
check_shop("Test")
|
|
print("Check complete.")
|