Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-05-08 22:23:00 +08:00
commit 4e6636c509
1500 changed files with 275211 additions and 0 deletions

36
utils/aio_print_api.py Normal file
View File

@@ -0,0 +1,36 @@
import requests
class AIOPrrintSystemAPI:
def __init__(self, api_url="http://127.0.0.1:5001/api/v1", api_key=""):
self.api_url = api_url
self.api_key = api_key
self.headers = {"X-Api-Key": self.api_key}
def _post_action(self, method, **kwargs):
url = f"{self.api_url}/octoprint_client"
payload = {"method": method, "kwargs": kwargs}
try:
r = requests.post(url, json=payload, headers=self.headers, timeout=5)
return r.json()
except:
return None
def print(self, *args, **kwargs):
pass
def get_status(self):
url = f"{self.api_url}/status"
try:
r = requests.get(url, headers=self.headers, timeout=5)
r.raise_for_status()
return r.json()
except:
return {"status": {}, "job": {}}
def pause_print(self):
return self._post_action("pause_print", action="pause")
def stop_print(self):
return self._post_action("cancel_print")