Task definition and Python script to upload from VS Code to CircuitPython board via web workflow REST API.
CircuitPython 8.x adds web workflow allowing code to be edited/uploaded via the local network. There is built-in browser support and also a Web REST API. This project utilizes the latter to upload a file directly from VS Code.
NOTE: This is very rough and you will find some bugs. No major bugs so far, but PRs for improvement appreciated!
- Python 3 installed and in your path.
- CircuitPython 8.x on your board.
- Board connected to same Wi-Fi with web workflow configured and reachable from machine running VS Code.
- Copy .vscode directory from this project to the root of your CircuitPython project. It does not have to be copied to your CircuitPython board, just the machine running VS Code.
- Edit .vscode/cp-web-upload.py and set baseURL.
- Web API password is taken from .env
- From the file you want to upload, execute the "Run Task..." command.
- Menu: Terminal, Run Task...
- Command pallet: Tasks: Run Task
- Shortcut keys: TODO:DOCUMENT_THESE
- Keybindings can be configured to call a specific task.
- Directories in the file's path are created if they don't exist.
- Only single files can be uploaded.
- Moved files will be recreated in the new location but the old file/directories will not be removed.
- Existing files will be overwritten, even if they haven't changed.
- get password from /.env
- set/get URL from /.env
- Get timestamp from source file and set on new file
- use argparse