Compare commits

..

2 Commits

4 changed files with 20 additions and 16 deletions

View File

@ -1,8 +1,8 @@
#ifndef DEFS_H
#define DEFS_H
#ifndef KQM_DEFS_H
#define KQM_DEFS_H
#define CR "\r"
#define LF "\n"
#define CRLF "\r\n"
#endif // DEFS_H
#endif // KQM_DEFS_H

View File

@ -1,5 +1,5 @@
#ifndef TYPES_H
#define TYPES_H
#ifndef KQM_TYPES_H
#define KQM_TYPES_H
#include <civetweb.h>
@ -8,4 +8,4 @@ typedef struct mg_context mg_context;
typedef struct mg_connection mg_connection;
typedef struct mg_request_info mg_request_info;
#endif // TYPES_H
#endif // KQM_TYPES_H

View File

@ -6,26 +6,18 @@
#include <stdio.h>
#include <string.h>
static int request_handler(mg_connection* conn, void* cbdata)
{
mg_printf(conn,
"HTTP/1.1 200 OK" CRLF "Content-Type: text/plain" CRLF "Connection: close" CRLF CRLF "Hello, World!");
return 200;
}
int main(int argc, char** argv)
{
const char* options[] = {"document_root", ".", "listening_ports", "8080", NULL};
const char* options[] = {"document_root", "./www", "listening_ports", "8080", NULL};
mg_callbacks callbacks;
mg_context* ctx;
memset(&callbacks, 0, sizeof(callbacks));
ctx = mg_start(&callbacks, NULL, options);
mg_set_request_handler(ctx, "/", request_handler, NULL);
// mg_set_request_handler(ctx, "/", request_handler, NULL);
printf("Server started on port(s) %s\n", mg_get_option(ctx, "listening_ports"));
getchar();
mg_stop(ctx);
}

View File

@ -13,3 +13,15 @@ target("math")
add_packages("civetweb")
add_includedirs("include")
add_files("src/main.c")
after_build(function (target)
local npm = "npm"
if is_host("windows") then
npm = "npm.cmd"
end
os.execv(npm, {"--prefix", "ui", "run", "build"})
local vue_dist_dir = "ui/dist"
local target_dir = target:targetdir() .. "/www"
os.cp(vue_dist_dir, target_dir)
end)