-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtestapp.c
More file actions
40 lines (25 loc) · 921 Bytes
/
Copy pathtestapp.c
File metadata and controls
40 lines (25 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#include "wui.h"
#include <stdio.h>
#include <string.h>
const char* test_html = "<h1>test</h1>";
void bind_callback(const char* json_args, wui_bind_result_t result, void* user_data) {
printf("args: %s\n", json_args);
wui_bind_set_result_json(result, "null");
}
int on_asset_request(const char* uri, wui_asset_response_t response, void* user_data) {
printf("asset request: %s\n", uri);
wui_asset_response_set_content_type(response, "text/html");
uint8_t* response_buffer = wui_asset_response_get_buffer(response, strlen(test_html));
memcpy(response_buffer, test_html, strlen(test_html));
return true;
}
int main() {
wui_glob_allow_inspect(true);
wui_view_t w = wui_new();
wui_set_html(w, "hello world from c!");
wui_bind_function(w, "test", bind_callback, NULL);
wui_on_asset_requested(w, on_asset_request, NULL);
wui_show(w);
wui_os_loop();
return 0;
}