#web-server #cli #http

bin+lib crab-http

A lightweight HTTP server for serving static files

2 releases

new 0.1.1 May 22, 2025
0.1.0 May 22, 2025

#1256 in Command line utilities

Apache-2.0 OR MIT

16KB
302 lines

Crab Http

This is a fast and lightweight (less than 2 MB) HTTP server written in Rust 🦀


Usage

  1. Installation

  1. Run the following command to start the server:
crab-http

Note: Make sure that port 8080 is not in use. You can change the port by using the --port flag. 3. Make your first request:

curl http://localhost:8080/echo/hello-world
  1. Run
crab-http --help

for more options.


Building from source:

  1. Make sure you have 🦀 Rust installed. You can install it from rustup.rs.
  2. Clone the repository:
git clone https://github.com/arjav0703/http-server.git
  1. Change to the directory:
cd http-server
  1. Build the project:
cargo build --release
  1. Run the server 🚀:
./target/release/crab-http

Features

  1. Port, directory, and write access configuration through command line arguments.

  2. File serving: You can access any file in the specified directory using the URL http://localhost:8080/files/<filename>.

  3. File Creation: You can create a file by sending a POST request with the file content to the URL http://localhost:8080/files/<filename>. The server will create a file with the specified name in the specified directory.

  4. File Updation: You can update a file by sending a POST request with the new content to the URL http://localhost:8080/files/<filename>. The server will update the file with the specified name in the specified directory.

  5. Route echo: You can echo any string using the URL http://localhost:8080/echo/<string>. The server will respond with the same string.

  6. User agent: The server will respond with the user agent string on sending a request to http://localhost:8080/user-agent.

  7. File Protection: The server will not allow access to files beginning with a '.' or a '_'

Dependencies

~1.4–8.5MB
~68K SLoC