SolarEnergy/python_device/src/api.py

15 lines
542 B
Python
Raw Normal View History

2024-06-29 16:05:58 +00:00
import requests
from src.args import args
def get_secure_origin() -> str:
res = requests.get(f"{args.unsecure_origin}/secure_origin")
if res.status_code < 200 or res.status_code > 299:
raise Exception(f"Get secure origin failed with status {res.status_code}")
2024-06-29 16:08:57 +00:00
return res.text
def get_root_ca() -> str:
res = requests.get(f"{args.unsecure_origin}/pki/root_ca.pem")
if res.status_code < 200 or res.status_code > 299:
raise Exception(f"Get root CA failed with status {res.status_code}")
return res.text