6 releases (breaking)

0.7.0 Sep 14, 2024
0.6.0 Jul 13, 2024
0.5.0 Jul 7, 2024
0.4.0 Jun 29, 2024
0.1.0 May 25, 2024

#990 in Command line utilities

Download history 113/week @ 2024-06-23 37/week @ 2024-06-30 200/week @ 2024-07-07 37/week @ 2024-07-14 94/week @ 2024-09-08 84/week @ 2024-09-15 11/week @ 2024-09-22 31/week @ 2024-09-29 6/week @ 2024-10-06

226 downloads per month

MIT license

62KB
1.5K SLoC

Simple Http Server

Simple http server writen from scratch in Rust. Implemented api endpoints allow for navigating file system directories, uploading and downloading files.

Features

  • Multi-threading
  • Dynamic routing
  • File upload/download
  • Static files serving
  • TLS/SSL support
  • Colorful terminal logs
  • CORS configuration
  • Basic HTTP Auth
  • Serve custom index html file

Usage

Simlpe HTTP Server with TLS/SSL support. Implemented api endpoints allow for navigating file system directories, uploading and downloading files.

Usage: http-server [OPTIONS]

Options:
  -p, --port <port>          Sets the port number [default: 7878]
  -t, --threads <threads>    Sets the number of threads [default: 12]
  -c, --cert <cert>          TLS/SSL certificate
      --certpass <certpass>  TLS/SSL certificate password
  -s, --silent               Disable logging
      --cors                 Enable CORS with Access-Control-Allow-Origin header set to *
      --ip <ip>              Ip address to bind to [default: 0.0.0.0]
  -a, --auth <auth>          Enable HTTP Basic Auth. Pass username:password as argument
      --compression          Enable gzip response compression
      --index <index>        Sets the path to custom index html file to serve
  -h, --help                 Print help
  -V, --version              Print version

Using the cert option

To use the cert option you have to:

  1. Generate the certificate with the following command: openssl req -x509 -newkey rsa:4096 -keyout myKey.pem -out cert.pem -days 365.
  2. Genenrate the pkcs12 file with the following command: openssl pkcs12 -export -out keyStore.p12 -inkey myKey.pem -in cert.pem
  3. Pass the cert and certpass arguments like this http-server -c ./keyStore.p12 --certpass yourPassword. Certpass option can be left blank if no password was set.

Dependencies

~5–17MB
~238K SLoC