# %%
import requests
import json

# %%

""" read problem data from json file """
filename= "data.json"
with open(filename) as json_file:
    data = json.load(json_file)
    
# optimize_courts(data,RUN_ENV='local')
    
    
# %%

""" create a new optimization task """
# res = requests.post("https://optimization.ligalytics.com/api/court/task/",
res = requests.post("http://localhost:8000/api/court/task/",
    headers={"Authorization": "3d9802e40000463b877bb26255915ca8"},
    json=data)


print(res.json())
# %%
""" receive task_id """
task_id = res.json()['task_id']
# print(res.json())

# %%

""" get the task status """
# res = requests.get(f"https://optimization.ligalytics.com/api/court/task?task_id={task_id}",
res = requests.get(f"http://localhost:8000/api/court/task?task_id={task_id}",
    headers={"Authorization": "3d9802e40000463b877bb26255915ca8"},
    json=[])

""" print the task result """
print(res.json())


# %%
