Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/maruel/serve-dir
"python -m SimpleHTTPServer" but FAST
https://github.com/maruel/serve-dir
go http-server
Last synced: 15 days ago
JSON representation
"python -m SimpleHTTPServer" but FAST
- Host: GitHub
- URL: https://github.com/maruel/serve-dir
- Owner: maruel
- License: apache-2.0
- Created: 2012-05-10T15:32:41.000Z (over 12 years ago)
- Default Branch: main
- Last Pushed: 2023-10-10T17:47:53.000Z (about 1 year ago)
- Last Synced: 2024-10-14T12:28:53.906Z (28 days ago)
- Topics: go, http-server
- Language: Go
- Homepage:
- Size: 15.6 KB
- Stars: 64
- Watchers: 5
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-golang-repositories - serve-dir - m SimpleHTTPServer" but FAST (Repositories)
README
# 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](https://pkg.go.dev/net/http#Handler) logging code in
`serve-dir` is usable as a library as `github.com/maruel/serve-dir/loghttp` via
[loghttp.Handler](https://pkg.go.dev/github.com/maruel/serve-dir/loghttp#Handler).[![Go
Reference](https://pkg.go.dev/badge/github.com/maruel/serve-dir/loghttp.svg)](https://pkg.go.dev/github.com/maruel/serve-dir/loghttp)Example:
```go
// 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())
```