libwizard

Crates.iolibwizard
lib.rslibwizard
version0.1.3
sourcesrc
created_at2023-07-19 10:41:08.473711
updated_at2023-07-19 10:44:45.389389
descriptionA crate for creating a simple http web server or a (somewhat static) API
homepage
repositoryhttps://github.com/Phant80m/HTML-rs/
max_upload_size
id920192
size24,860
Nicholas Samuels (Phant80m)

documentation

README

HTML-rs

Simple rust library to write and server html directly from a program

Example

use libwizard::prelude::*;

fn main() {
    let server = Server::new("127.0.0.1", 8080);
    let custom_routes = vec![
        CustomRoutes::new(
            "/about",
            "text/html",
            include_html("./about.html"),
            Some("./about.css"),
        ),
        CustomRoutes::new(
            "/api",
            "application/json",
            "{\"name\": \"John\", \"age\": 30}",
            None::<String>,
        ),
    ];

    server.start(
        ServerResponse::new(include_html("./index.html")),
        StyleResponse::new("./style.css"),
        custom_routes,
        Custom404::new(include_html("./404.html")),
    );
}

Commit count: 24

cargo fmt