Website under construction
Here at Rohanasan we focus on extreme optimization, performance and ease of use.
This is a basic hello world implementation in Rohanasan backend framework (Rust)
use rohanasan::{
rohanasan, send_http_response, serve, Request, DEFAULT_HTML_HEADER,
};
fn handle(req: Request) -> String {
send_http_response(DEFAULT_HTML_HEADER, "Hello!
", req)
}
fn main() {
rohanasan! {
serve(8080, handle)
}
}
Read more
An example to send a html file named index.html present inside html folder. It also checks if the request made was a get request or a post request if, the path is / it returns an index.html persent inside ./html directory.
use rohanasan::{
rohanasan, send_file, send_http_response, serve, url_decode, Request, DEFAULT_HTML_HEADER,
};
fn handle(req: Request) -> String {
if req.path == "/" {
send_file(DEFAULT_HTML_HEADER, "./html/hello.html", req)
} else if req.path == "/hello" {
send_http_response(DEFAULT_HTML_HEADER, "Hi, How are you?
", req)
} else if req.path == "/req" {
if url_decode(req.get_request) == "q=hello world" {
send_http_response(DEFAULT_HTML_HEADER, "Hi world!
", req)
} else {
send_http_response(DEFAULT_HTML_HEADER, "World?
", req)
}
} else {
send_file(DEFAULT_HTML_HEADER, "./html/404.html", req)
}
}
fn main() {
rohanasan! {
serve(8080, handle)
}
}
Read more