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 (C/C++)
use rohanasan::{
rohanasan, send_http_response, serve, Request, DEFAULT_HTML_HEADER,
};
fn handle(req: Request) -> String {
send_http_response(DEFAULT_HTML_HEADER, "Hello!
", req.data)
}
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.data)
} else if req.path == "/hello" {
send_http_response(DEFAULT_HTML_HEADER, "Hi, How are you?
", req.data)
} else if req.path == "/req" {
if url_decode(req.get_request) == "q=hello world" {
send_http_response(DEFAULT_HTML_HEADER, "Hi world!
", req.data)
} else {
send_http_response(DEFAULT_HTML_HEADER, "World?
", req.data)
}
} else {
send_file(DEFAULT_HTML_HEADER, "./html/404.html", req.data)
}
}
fn main() {
rohanasan! {
serve(8080, handle)
}
}
Read more
Just follow the following steps:
curl https://raw.githubusercontent.com/rohanasan/rohanasan_c/main/project_maker.c -o project_maker.c
gcc ./project_maker.c
./a.out
rm ./project_maker.c
rm ./a.out