| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | brt_serve() { |
| 4 | local port="${1:-8080}" |
| 5 | local dir="${2:-.}" |
| 6 | brt_require python3 |
| 7 | |
| 8 | if [[ ! -d "$dir" ]]; then |
| 9 | brt_error "Directory not found: ${dir}" |
| 10 | exit 1 |
| 11 | fi |
| 12 | |
| 13 | brt_info "Serving ${dir} on http://0.0.0.0:${port}" |
| 14 | brt_info "Press Ctrl+C to stop" |
| 15 | python3 -m http.server "$port" --directory "$dir" --bind 0.0.0.0 |
| 16 | } |
| 17 | |