lsdserver

Crates.iolsdserver
lib.rslsdserver
version
sourcesrc
created_at2025-03-17 11:58:36.00538+00
updated_at2025-03-17 11:58:36.00538+00
descriptionLightweight dependency-free HTTP server Library in Rust
homepagehttps://github.com/linuxfanboy4/lsdserver.git
repository
max_upload_size
id1595382
Cargo.toml error:TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
(linuxfanboy4)

documentation

README

LSD Server

LSD Server is a lightweight, dependency-free HTTP server library written in Rust. It is designed to be simple, fast, and easy to use, making it an ideal choice for serving static files or building small web applications. The library is minimalistic, with no external dependencies, ensuring that your project remains lightweight and efficient.

Features

  • Lightweight: No external dependencies, ensuring minimal overhead.
  • Simple API: Easy-to-use functions for starting a server and handling connections.
  • Static File Serving: Serve HTML, CSS, JavaScript, and other static files with automatic content type detection.
  • Customizable: Easily extendable to handle more complex use cases.

Installation

To add LSD Server to your project, use Cargo:

cargo add lsdserver

This will add the latest version of LSD Server to your Cargo.toml file.

Usage

Basic Example

Here's a simple example of how to use LSD Server to serve static files:

use lsdserver::{start_server, handle_connection};

fn main() {
    // Start the server on localhost:8080
    start_server("127.0.0.1:8080");
}

This will start an HTTP server on 127.0.0.1:8080. By default, the server will serve files from the current directory. For example, if you have an index.html file in the root directory, it will be served when you navigate to http://127.0.0.1:8080/.

Handling Connections

The handle_connection function is responsible for processing incoming HTTP requests. It reads the request, determines the requested file, and serves it with the appropriate content type. If the file does not exist, it returns a 404 Not Found response.

Starting the Server

The start_server function binds the server to the specified address and starts listening for incoming connections. It prints a message to the console indicating that the server has started.

Customization

LSD Server is designed to be simple, but it can be easily extended to handle more complex use cases. For example, you can modify the handle_connection function to implement custom routing, middleware, or other advanced features.

License

LSD Server is licensed under the MIT License. See the LICENSE file for more details.

Commit count: 0

cargo fmt