返回资讯中心
外部精选
软件工程
#开发者实时流

Show HN: Dirjet – A fast, secure local file server that just works

A Rust static file server for directories and individual files.

Hacker News 最新modinfo2026/10/31 · 今天8 分钟阅读

以下正文同步自 Hacker News 最新,版权归原站所有,已转换为易读排版。

A Rust static file server for directories and individual files.

Run it with npx or bunx. No configuration file or Rust toolchain required.

Runs a native binary, downloaded and cached for your OS and CPU.

Serves index.html files, directory listings, or a single file with its relative assets.

Supports file streaming, MIME types, HEAD requests, byte ranges, and conditional caching.

Blocks dotfiles, parent directory traversal, and symlinks that resolve outside the document root.

Quick start

Requires Node.js 18+ or Bun.

Serve a specific directory

npx dirjet ./my-website

Serve a single HTML file

npx dirjet index.html

Serve the current directory

npx dirjet

The server listens at http://127.0.0.1:3000 by default. Stop it with Ctrl+C.

With Bun, use bunx dirjet ./my-website. If Node.js is not installed, use bunx --bun dirjet ./my-website to run the launcher with Bun.

Directories

Directories serve index.html when present, otherwise they show a directory listing. Directory URLs redirect to a trailing slash so relative assets resolve correctly.

Passing a file, such as npx dirjet presentation.html, serves it at / and /presentation.html. Its parent directory becomes the document root so relative stylesheets, scripts, and images work, including assets in subdirectories.

Other non-hidden files in that parent directory are also accessible by URL. Directory listings are disabled in single-file mode.

dirjet serves static files. Build TypeScript, JSX, and other frontend source assets before serving them. It does not transpile code, provide live reload, or terminate TLS.

dirjet [OPTIONS] [PATH]

Option Default What it does

-p, --port <PORT> 3000 Change the server port. Use 0 to automatically pick an available port.

-l, --listen <PORT> 3000 Alias for --port.

--host <IP> 127.0.0.1 Bind to a specific IP address. Use 0.0.0.0 to make the server accessible to other devices on your local network.

-s, --single Off Single-page app mode. Serve the entry file for missing extensionless routes.

--no-listing Off Returns a 404 Not Found for directories that don't have an index.html file, instead of showing a directory list.

-h, --help

Show the help menu.

-V, --version

Show the current version.

Serve a single-page app

npx dirjet -s ./dist -p 8080

Missing routes such as /users/42 return index.html so your frontend router can handle them. Missing assets such as /missing.js still return 404. When serving a single file, --single uses that file as the fallback.

On first run, the JavaScript launcher downloads the native binary for your OS and CPU from the matching GitHub release. It verifies the binary's SHA-256 checksum before running it and saves it in your OS cache directory. The first run needs access to GitHub Releases.

Later runs verify and reuse the cached binary. Each version has a separate cache entry. Interrupted or invalid downloads are discarded. No postinstall scripts run.

Prebuilt binaries support Linux, macOS, and Windows on x64 and ARM64.

Set DIRJET_CACHE_DIR to use a custom, writable cache directory.

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →