2 releases
new 0.1.1 | May 22, 2025 |
---|---|
0.1.0 | May 22, 2025 |
#1256 in Command line utilities
16KB
302 lines
Crab Http
This is a fast and lightweight (less than 2 MB) HTTP server written in Rust 🦀
Usage
-
Installation
cargo install crab-http
- Download the binary from github releases.
- 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
- Run
crab-http --help
for more options.
Building from source:
- Make sure you have 🦀 Rust installed. You can install it from rustup.rs.
- Clone the repository:
git clone https://github.com/arjav0703/http-server.git
- Change to the directory:
cd http-server
- Build the project:
cargo build --release
- Run the server 🚀:
./target/release/crab-http
Features
-
Port, directory, and write access configuration through command line arguments.
-
File serving: You can access any file in the specified directory using the URL
http://localhost:8080/files/<filename>
. -
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. -
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. -
Route echo: You can echo any string using the URL
http://localhost:8080/echo/<string>
. The server will respond with the same string. -
User agent: The server will respond with the user agent string on sending a request to
http://localhost:8080/user-agent
. -
File Protection: The server will not allow access to files beginning with a '.' or a '_'
Dependencies
~1.4–8.5MB
~68K SLoC