commit 8daba43d772530360f9eea4b8e35a9caf2490c5c
parent 589ab4c6b10d05f1e8da4ea989afd43854b3f9f0
Author: Chris Roberts <chris.roberts@learningunix.net>
Date: Wed, 15 Jul 2026 04:51:38 -0500
Add GET /jobs/<name> with 404 for unknown jobs
This is the lookup step the eventual job-triggering endpoint
will need anyway, split out on its own since it's read-only
(a safe HTTP method) and doesn't require pexpect at all.
Triggering a job will be a separate POST endpoint, since
running rip has real side effects and shouldn't be a GET.
Diffstat:
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/simplefe/app.py b/src/simplefe/app.py
@@ -1,4 +1,5 @@
-from flask import Flask
+from flask import Flask, abort
+
from simplefe.config import load_jobs
@@ -18,4 +19,11 @@ def create_app(jobs=None):
def list_jobs():
return {"jobs": list(app.config["JOBS"].keys())}
+ @app.route("/jobs/<name>")
+ def get_job(name):
+ jobs = app.config["JOBS"]
+ if name not in jobs:
+ abort(404)
+ return jobs[name]
+
return app
diff --git a/tests/test_app.py b/tests/test_app.py
@@ -1,3 +1,13 @@
def test_list_jobs(client):
response = client.get("/jobs")
assert response.json == {"jobs": ["rip"]}
+
+
+def test_get_job(client):
+ response = client.get("/jobs/rip")
+ assert response.json == {"path": "/fake/path"}
+
+
+def test_get_job_not_found(client):
+ response = client.get("/jobs/nonexistent")
+ assert response.status_code == 404