搜尋套件、儲存庫與 APP 分類

套件詳情v4.3.0

dhttpd

用於輕鬆本地託管目錄的靜態HTTP檔案伺服器。

AndroidiOSmacOSWindowsLinux
近 30 天下載
3640
喜歡數
141
Pub 分數
140

安裝套件

flutter pub add dhttpd

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

dhttpd 是一個為 Flutter 構建的輕量級靜態 HTTP 檔案伺服器,可輕鬆實現目錄內容的本機託管。它允許開發者從指定目錄透過 HTTP 提供檔案,非常適合測試網頁資源、提供靜態網站,或在開發過程中本地分享檔案。該伺服器可在 Android、iOS、macOS、Windows 和 Linux 等多個平台運行,適用於跨平台工作流程。設定簡單,dhttpd 提供了一種無需複雜設定即可預覽或分享內容的便捷方式。

適用情境

  • 本地開發預覽
  • 提供靜態 Web 資產
  • 測試 Web 應用程式
  • 在設備間共用檔案
  • 快速原型設計

主要特色

  • 簡單設定
  • 跨平台支援
  • 靜態檔案服務
  • Lightweight
  • 在所有主要平台運行

適合對象

  • Flutter 開發者
  • 前端測試人員
  • 本機 Web 伺服器需要
  • Prototyping
  • 開發環境

使用建議

  • 不適用於生產環境
  • 僅限靜態檔案
  • 未進行身分驗證
  • 需要手動設定以進行進階設定
  • 不適合動態內容

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

Pub Package CI package publisher

A simple HTTP server that can serve up any directory, built with Dart. Inspired by python -m SimpleHTTPServer.

Install

Use the dart pub global command to install this into your system.

$ dart pub global activate dhttpd

Use

If you have modified your PATH, you can run this server from any local directory.

$ dhttpd

Otherwise you can use the dart pub global command.

$ dart pub global run dhttpd

Here's an example of creating a web app and then running it with this server:

$ dart create -t web web_app
$ cd web_app
$ dart pub get
$ dart run build_runner build -o build
$ dhttpd --path build/web/  # Serves app at http://localhost:8080
HTTPS

If you want to use HTTPS you will need to pass in the path of the SSL certificate and the SSL key file as well as the password string, if a password is set on the key, for example:

$ dart bin/dhttpd.dart --sslcert=example/server_chain.pem --sslkey=example/server_key.pem --sslkeypassword=dartdart
Server HTTPS started on port 8080

See the Dart documentation of SecurityContext.usePrivateKey for more details.

Configure

$ dhttpd --help
    --headers=<headers>                  HTTP headers to apply to each response. Can be used multiple times. Format: header=value;header2=value
    --host=<host>                        The hostname to listen on.
                                         (defaults to "localhost")
-l, --list-files                         List the files in the directory if no index.html is present.
    --path=<path>                        The path to serve. If not set, the current directory is used.
-p, --port=<port>                        The port to listen on. Provide `0` to use a random port.
                                         (defaults to "8080")
-q, --quiet                              Disable logging.
    --sslcert=<sslcert>                  The SSL certificate to use. Also requires sslkey
    --sslkey=<sslkey>                    The key of the SSL certificate to use. Also requires sslcert
    --sslkeypassword=<sslkeypassword>    The password for the key of the SSL certificate to use.
-h, --help                               Displays the help.
    --version                            Prints the version of dhttpd.

所屬分類

依賴

依賴清單 4 項

原始碼儲存庫

使用此套件的專案