Search packages, repositories and app categories

Package detailsv4.3.0

dhttpd

A static HTTP file server for easy local hosting of a directory.

AndroidiOSmacOSWindowsLinux
30-day downloads
3.6K
Likes
141
Pub points
140

Install package

flutter pub add dhttpd

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

dhttpd is a lightweight, static HTTP file server built for Flutter that enables easy local hosting of directory contents. It allows developers to serve files over HTTP from a specified directory, ideal for testing web assets, serving static sites, or sharing files locally during development. The server runs on multiple platforms including Android, iOS, macOS, Windows, and Linux, making it versatile for cross-platform workflows. With minimal setup, dhttpd provides a simple way to preview or share content without complex configurations.

Use cases

  • Local development previews
  • Serving static web assets
  • Testing web applications
  • Sharing files across devices
  • Quick prototyping

Key features

  • Simple setup
  • Cross-platform support
  • Static file serving
  • Lightweight
  • Runs on all major platforms

Suitable for

  • Flutter developers
  • Frontend testers
  • Local web server needs
  • Prototyping
  • Development environments

Considerations

  • Not for production use
  • Limited to static files
  • No authentication
  • Requires manual configuration for advanced settings
  • Not suitable for dynamic content

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

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.

Categories

Dependencies

Dependency list 4 items

Source repository

Projects using this package