FastAPI router and job engine for streaming G-code to GRBL controllers
Project description
pygrbl-server
FastAPI router and thread-safe job engine for streaming G-code to GRBL controllers. A library, not an application: mount the router in your own FastAPI app and run it with the ASGI server of your choice. One active job per serial port, live status, and a retained terminal result per port.
Part of the pygrbl family: pygrbl-build (generate G-code) → pygrbl-streamer (stream to GRBL) → pygrbl-server (expose over HTTP).
Install
pip install pygrbl-server
Dependencies: fastapi and pygrbl-streamer. Bring your own ASGI server.
Usage
from contextlib import asynccontextmanager
from fastapi import FastAPI
from pygrbl_server import JobRegistry, create_router
registry = JobRegistry() # streamer_factory(port, baudrate), defaults to GrblStreamer
@asynccontextmanager
async def lifespan(app: FastAPI):
yield
registry.shutdown()
app = FastAPI(lifespan=lifespan)
app.include_router(create_router(registry))
uvicorn yourmodule:app --host 0.0.0.0 --port 8000
Events are logged to the pygrbl_server logger (alarms and failures at
WARNING/ERROR). Inject a custom streamer_factory to swap the streamer backend.
API
| Endpoint | Description |
|---|---|
POST /stream |
Start a job: {"port": "...", "files": [...]}. 202 started, 409 port busy, 404 file missing. |
POST /stop?port= |
Cancel the active job. 404 if none. |
POST /pause?port=&paused= |
Feed hold (true, default) or resume (false). 404 if none. |
GET /status?port= |
Port state; omit port for all ports. |
Status is idle, working, paused, or the retained done / error of the
last finished job (kept until a new job starts on that port):
curl 'localhost:8000/status?port=/dev/ttyUSB0'
# {"port": "/dev/ttyUSB0", "status": "working", "progress": 42, "error": null}
Security
No authentication. Any client that can reach the port can control physical
machines capable of causing fires or injury. Run on a trusted LAN only. The
files in /stream are paths on the server's filesystem, not uploads. Auth,
TLS, and rate limiting belong in the app that mounts the router.
Design
The library streams files and reports state; everything else lives in your layers:
- Machine setup (homing, air assist, preambles) belongs in your G-code.
- Delays between files:
M5+G4 P<seconds>in your G-code. - Notifications: poll
/statusor attach a handler to thepygrbl_serverlogger. - Runner, CLI, auth, CORS: your app's job — this ships as a router on purpose.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pygrbl_server-0.0.1.tar.gz.
File metadata
- Download URL: pygrbl_server-0.0.1.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3555d6bcd4720176f246d9bf15e46ac0dbaa4f154ac36aacc9b8d1c0bc7f2bbd
|
|
| MD5 |
0900b47c638110f2a91534eb060cc35f
|
|
| BLAKE2b-256 |
4e9ad4cb36fbe208eb575f5dabdcad4e8958ebe9c02c77ec1dc9d933b219503a
|
Provenance
The following attestation bundles were made for pygrbl_server-0.0.1.tar.gz:
Publisher:
publish.yml on offerrall/pygrbl-server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygrbl_server-0.0.1.tar.gz -
Subject digest:
3555d6bcd4720176f246d9bf15e46ac0dbaa4f154ac36aacc9b8d1c0bc7f2bbd - Sigstore transparency entry: 2051084437
- Sigstore integration time:
-
Permalink:
offerrall/pygrbl-server@d41989e81a8135fa27fa7d02eb2dd44c3bdd365c -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/offerrall
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d41989e81a8135fa27fa7d02eb2dd44c3bdd365c -
Trigger Event:
release
-
Statement type:
File details
Details for the file pygrbl_server-0.0.1-py3-none-any.whl.
File metadata
- Download URL: pygrbl_server-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf97f3ae9ef4930141f768bb8b8f599988a98fc468e6c4cd4bfaeb0754deb417
|
|
| MD5 |
866db78d803377654e13494d7adb090b
|
|
| BLAKE2b-256 |
12f4b2ae82ab3fbb393f648008dcb6abc22fcb2fa40d4beb52224f88316962bb
|
Provenance
The following attestation bundles were made for pygrbl_server-0.0.1-py3-none-any.whl:
Publisher:
publish.yml on offerrall/pygrbl-server
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pygrbl_server-0.0.1-py3-none-any.whl -
Subject digest:
bf97f3ae9ef4930141f768bb8b8f599988a98fc468e6c4cd4bfaeb0754deb417 - Sigstore transparency entry: 2051084779
- Sigstore integration time:
-
Permalink:
offerrall/pygrbl-server@d41989e81a8135fa27fa7d02eb2dd44c3bdd365c -
Branch / Tag:
refs/tags/v0.0.1 - Owner: https://github.com/offerrall
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d41989e81a8135fa27fa7d02eb2dd44c3bdd365c -
Trigger Event:
release
-
Statement type: