#!/usr/bin/env python3
import urllib.request
import json
url = 'http://octoprint:5000/api/printer/command'
json_data = json.dumps(
{
'command': 'M18 X Y Z',
}
).encode("utf-8")
with open('api-key') as f:
api_key = f.read().rstrip()
req = urllib.request.Request(url)
req.add_header('X-Api-Key', api_key)
req.add_header('Content-Type', 'application/json')
req.data = json_data
with urllib.request.urlopen(req) as f:
print(f.read().decode())
0 件のコメント:
コメントを投稿