Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Latest commit

History

History
42 lines (29 loc) * 1.03 KB

returning_values_html.md

File metadata and controls

42 lines (29 loc) * 1.03 KB

Returning Values - HTML

To generate HTML from a file, the cweb_send_var_html function may be used:

#include "CWebStudioOne.c"

struct CwebHttpResponse *main_sever(struct CwebHttpRequest *request ){

const char *html = "

Hello World

"
;
return cweb_send_var_html(html,200);
}

int main(int argc, char *argv[]){
CwebServer server = newCwebSever(5000, main_sever);
CwebServer_start(&server);
return 0;
}

As is done with returning plain text, memory will be automatically cleaned with cweb_send_var_html_cleaning_memory:

#include "CWebStudioOne.c"

struct CwebHttpResponse *main_sever(struct CwebHttpRequest *request ){

char *html = (char*)malloc(1000);
strcat(html, "

Hello World

"
);
return cweb_send_var_html_cleaning_memory(html,200);
}

int main(int argc, char *argv[]){
CwebServer server = newCwebSever(5000, main_sever);
CwebServer_start(&server);
return 0;
}

These examples show how to return HTML responses.