basi_css

Crates.iobasi_css
lib.rsbasi_css
version0.2.22
sourcesrc
created_at2024-10-17 18:52:25.322923
updated_at2024-10-18 14:36:57.170948
descriptionCSS framework using tiny_http
homepage
repositoryhttps://github.com/LemonsSquirrel/BasiCss
max_upload_size
id1413519
size72,444
(LemonsSquirrel)

documentation

README

BasiCss

A CSS framework insipred by Tailwind CSS.

Attention

This project is still in development, use it with another CSS file to complement it for now, i will try to do frequent updates! But, for now, Enjoy! Feel free to tell me if you find any problem with the README, i will try to update it for other http frameworks as well.

Usage

With tiny_http

main.rs

use tiny_http::{Server, Request, Response};
// import the module
use basi_css::serve_css;

fn main() {
    // We create the server
    let server = Server::http("127.0.0.1:8080").unwrap();
    println!("Server started at http://127.0.0.1:8080");

    for request in server.incoming_requests() {
        // If the request is for the css file, we serve it
        if request.url() == "/css/basicss.css" {
            let response = serve_css(request);
            server.respond(response).unwrap();
        } else {
            // Otherwise, we respond with a 404 error.
            server.respond(Response::from_string("404 Not Found".to_string())).unwrap();
        }
    }
}

index.html

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="/css/basicss.css">
</head>
<body>
    <nav class="navbar navbar-dark"></nav>
    <main class="width-100-percents height-100-percents flex justify-center width-100-percents flex-column" >
        <h1>Hello, World!</h1>
    </main>
    <footer class="footer footer-dark"></footer>
</body>
</html>

Result

example.png

Commit count: 0

cargo fmt