Skip to content

Instantly share code, notes, and snippets.

@rsbohn
Created September 3, 2022 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rsbohn/7be7b8278a9c2b7c38353736573b48a2 to your computer and use it in GitHub Desktop.
Save rsbohn/7be7b8278a9c2b7c38353736573b48a2 to your computer and use it in GitHub Desktop.
Exploring the CircuitPython 8 Web Workflow

Command Line access to CircuitPython 8 Web Workflow

via HTTPie

Hello? Are you there?

$ http http://circuitpython.local

HTTP/1.1 307 Temporary Redirect
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin:
Connection: close
Content-Length: 0
Location: http://cpy-41f05c.local/
Vary: Origin, Accept, Upgrade

You get a 307 Temporary Redirect. The hostname (cpy-41f05c) is derived from the cpu-id. Use the URL in the "Location" header to get the device homepage:

$ http://cpy-41f05c.local/

<!doctypehtml>
<title>CircuitPython</title>
<meta charset=UTF-8>
<meta content=width=device-width,initial-scale=1 name=viewport>
<script defer src=/welcome.js></script>
<link href=/style.css rel=stylesheet>
<link href=http://circuitpython.org/assets/css/webworkflow-8.css rel=stylesheet>
<body>
<h1>
<a href=/><img src=/favicon.ico></a> Welcome!</h1><p>Welcome to CircuitPython's Web API. 
Go to the <a href=/fs/>file browser</a> to work with files in the CIRCUITPY drive. 
Go to the <a href=/cp/serial/>serial terminal</a> to see code output and interact with the REPL. 
Make sure you've set <code>CIRCUITPY_WEB_API_PASSWORD='somepassword'</code> in <code>/.env</code>. 
Provide the password when the browser prompts for it. 
<strong>Leave the username blank.</strong>

<h2>Device Info:</h2>
<dl><dt>Board:<dd><a id=board></a><dt>Version:<dd><span id=version></span>
<dt>Hostname:<dd><a id=hostname></a>
<dt>IP:<dd><a id=ip></a></dl>

<h2>Here are other CircuitPython devices on your network:</h2><ul id=devices></ul>

Tell me about yourself

Let's have a look at the boot_out.txt file. We need to use HTTP Basic Authentication with an empty username.

$ http -a :my-secure-password http://cpy-41f05c.local/fs/

HTTP/1.1 200 OK
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin:
Content-Length: 134
Content-Type: text/plain;charset=UTF-8
Vary: Origin, Accept, Upgrade

Adafruit CircuitPython 8.0.0-beta.0-8-gb48141154 on 2022-08-24; ProS3 with ESP32S3
Board ID:unexpectedmaker_pros3
UID:4F21AF140FC5

Issues

Basic Authentication

  • Not secure, but we all know that, right?
  • Empty User Name: PowerShell has support for basic authentication, but it requires a user name.

307 Temporary Redirect

  • Possibly just user error, but if I provide the credentials for basic authentication they don't survive the redirect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment