Skip to content

Instantly share code, notes, and snippets.

@nezuppo
Created April 29, 2019 10:31
Show Gist options
  • Save nezuppo/fef12e2004f0a39a0d798ade45d59496 to your computer and use it in GitHub Desktop.
Save nezuppo/fef12e2004f0a39a0d798ade45d59496 to your computer and use it in GitHub Desktop.
python で OctoPrint API にアクセス
#!/usr/bin/env python3
import urllib.request
def main():
req = urllib.request.Request('http://octoprint:5000/api/connection')
req.add_header('X-Api-Key', 'C14B4FA3BE854CAAA740A43BEAFD6FB3')
with urllib.request.urlopen(req) as f:
print(f.read().decode())
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment