A simple Python FastAPI application that reads local files and exposes a REST API to return file content and metadata.
- Python 3.8 or higher
- uv package manager
- Install dependencies using uv:
uv sync- Run the application:
uv run python run.py
# OR
uv run uvicorn app.main:app --host 0.0.0.0 --port 8000 --reloadThe API will be available at http://localhost:8000
curl http://localhost:8000/api/prompt-templatesResponse:
{
"prompts": [
{
"name": "hello",
"code": 1,
"scope": "Word",
"params": {
"mandatory": ["name"],
"optional": ["original_content"]
},
"file": "hello.txt"
}
]
}curl "http://localhost:8000/api/prompt-templates?code=1"Response:
{
"prompt": {
"name": "hello",
"code": 1,
"scope": "Word",
"params": {
"mandatory": ["name"],
"optional": ["original_content"]
},
"content": "Hello, {name}! Welcome!\n\n{original_content}"
}
}GET /- API informationGET /health- Health checkGET /docs- Interactive API documentation (Swagger UI)
uv run pytest tests/ -v# Add to main dependencies
uv add package-name
# Add to dev dependencies
uv add --dev package-name
# Check what's installed
uv pip list
# Update dependencies
uv sync --upgrade
# Remove dependencies
uv remove package-name
# Show dependency tree
uv tree