Crates.io | libwizard |
lib.rs | libwizard |
version | 0.1.3 |
source | src |
created_at | 2023-07-19 10:41:08.473711 |
updated_at | 2023-07-19 10:44:45.389389 |
description | A crate for creating a simple http web server or a (somewhat static) API |
homepage | |
repository | https://github.com/Phant80m/HTML-rs/ |
max_upload_size | |
id | 920192 |
size | 24,860 |
Simple rust library to write and server html directly from a program
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")),
);
}