Skip to content

Serve images as static files via /images/ route#19

Draft
Copilot wants to merge 2 commits into
mainfrom
copilot/static-image-access
Draft

Serve images as static files via /images/ route#19
Copilot wants to merge 2 commits into
mainfrom
copilot/static-image-access

Conversation

Copilot AI commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Images were served through an API handler (/api/image/<filename>) that added Python overhead on every request, used send_file with a manually-constructed path (path traversal risk), and required manual MIME type detection.

Changes

vest/app.py

  • New /images/<path:filename> route replaces /api/image/ — delegates directly to send_from_directory(app.image_base_path, filename), which enforces directory confinement, handles MIME types automatically, and enables proper HTTP caching semantics
  • Fixed path traversal in /api/keyframes/load — user-supplied filename was passed directly to os.path.join(cwd, filename); replaced with a glob-based lookup so the file path is never constructed from user input

vest/static/viewer.js

  • Updated image URL template from `/api/image/${filename}``/images/${filename}`

tests/test_app.py (new)

  • Tests for the /images/ route: no base path, successful serve, missing file, and path traversal rejection

DEVELOPMENT.md

  • Updated route reference from GET /api/image/<filename> to GET /images/<filename>

Copilot AI linked an issue Jun 9, 2026 that may be closed by this pull request
Copilot AI changed the title [WIP] Load images directly from folder instead of API calls Serve images as static files via /images/ route Jun 9, 2026
Copilot AI requested a review from haesleinhuepf June 9, 2026 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Static image access

2 participants