Repository navigation
feat(server): serve an optional static directory - #2456
Open
original4422 wants to merge 2 commits into
Open
original4422 wants to merge 2 commits into
original4422 wants to merge 2 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add an optional
--static_dir/STATIC_DIR/ top-level configstatic_dirsetting for serving a local HTML client and assets alongside the API. Static serving stays off by default.Fixes #1060. Directory requests can serve
index.html; existing API routes take precedence. Static files are public even whenapi_keyis set, while bearer checks on API routes remain unchanged. Starlette's default directory confinement is retained.Evidence
After: four actual subprocess servers cover CLI, environment, JSON config and default-off behavior. All 12 HTTP/native cases pass, including public assets, traversal/external-symlink rejection, API routing, bearer 401/200 and real CPU completion.
make testwithLLAMA_CPP_TEST_MODELpointing to a local ggml-orgstories15M-q4_0.ggufandPYTEST_ADDOPTSselectingtest_server_static.py,test_llama_chat_format.py,test_llama_grammar.pyandtest_llama_speculative.py: 18 passed, no skips, including 12 new integrated regression cases. Native cases opt in through that variable and do not download weights.make lint: Ruff checks and formatting pass for all 30 Python source/test files.Validated on macOS arm64, Python 3.12.14, vendored llama.cpp
f5e6915c2, withn_gpu_layers=0and real model execution. The model-downloadingtest_llama.pysuite, GPU platforms and performance were not tested.Implemented and reviewed by Codex as the author's authorized agent.
Merge Danger
Door: two-way
Blast Radius: server
Only an explicitly configured directory is served; it must contain files intended for public access.