Created
April 29, 2019 10:31
-
-
Save nezuppo/fef12e2004f0a39a0d798ade45d59496 to your computer and use it in GitHub Desktop.
python で OctoPrint API にアクセス
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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