Skip to content

will8ug/file-reader-api

Repository files navigation

File Reader API

A simple Python FastAPI application that reads local files and exposes a REST API to return file content and metadata.

Setup

Prerequisites

  • Python 3.8 or higher
  • uv package manager

Installation

  1. Install dependencies using uv:
uv sync
  1. Run the application:
uv run python run.py
# OR
uv run uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload

The API will be available at http://localhost:8000

API Usage

Get All Prompts (Metadata Only)

curl http://localhost:8000/api/prompt-templates

Response:

{
  "prompts": [
    {
      "name": "hello",
      "code": 1,
      "scope": "Word",
      "params": {
        "mandatory": ["name"],
        "optional": ["original_content"]
      },
      "file": "hello.txt"
    }
  ]
}

Get Specific Prompt (With Content)

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}"
  }
}

Other Endpoints

  • GET / - API information
  • GET /health - Health check
  • GET /docs - Interactive API documentation (Swagger UI)

Development

Running Tests

uv run pytest tests/ -v

📚 More UV Commands

# 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages