Http Helper

From Onix OS Wiki
Jump to: navigation, search

If we are going to do a test to render HTML, we can write the HTML module first so that we can link it to the http socket and render it.

Definition

http(PATH OR PORT,
  IF PATH DEFINED PORT,
  ...config or result string )
);

Allows you to create http sockets. However, as the router works, improvements to the function continue. This can be removed in the future or replaced by the router function.

Example

httprenderexample.ol

show("Listening 0.0.0.0:8080... Ctrl+C to exit.");
http("/",
  "8080",
  "Hello, Olang World from Web!")
);


I started a sample http socket by including the jquery script and other plugins in my html parameters. As a result, when I call the socket with curl;

~> curl localhost:8080
.....content....

I gave an HTML output as a conversion. This will be similarly rendered on the Web.