Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

maruel/serve-dir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

15 Commits

Repository files navigation

Serves a directory over HTTP

I was extremely annoyed at python -m SimpleHTTPServer (lack of) speed so I wrote one.

This project depends only on stdlib on purpose.

Installation

go install github.com/maruel/serve-dir@latest

Usage

Serve the current directory:

serve-dir

Help with the command line arguments available:

serve-dir -help

Example output

11:15:52.282045 Serving /home/my_account/src on port 8010
11:15:53.916813 192.168.1.2:2092 - 304 0b GET /src/
11:15:54.010258 192.168.1.2:2092 - 404 19b GET /favicon.ico
11:16:08.770496 192.168.1.2:2094 - 200 8877b GET /src/foo.json

Logging library

The http.Handler logging code in serve-dir is usable as a library as github.com/maruel/serve-dir/loghttp via loghttp.Handler.

Go Reference

Example:

// Serves the current directory over HTTP and logs all requests.
log.SetFlags(log.Lmicroseconds)
s := &http.Server{
 Addr: ":6060",
 Handler: &loghttp.Handler{Handler: http.FileServer(http.Dir("."))},
}
log.Fatal(s.ListenAndServe())

About

"python -m SimpleHTTPServer" but FAST

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /