我正在尝试在猫鼬服务器中显示一个 html 页面,我尝试使用以下代码,但它不起作用,谁能告诉我该代码中的问题是什么。
#include <stdio.h>
#include <string.h>
#include "mongoose/mongoose.h"
static int begin_request_handler(struct mg_connection *conn) {
const struct mg_request_info *request_info = mg_get_request_info(conn);
static const char *login_url = "/index.html";
mg_printf(conn, "HTTP/1.1 200 OK\r\n"
"Content-Type: text/html\r\n"
"Location: %s\r\n\r\n", login_url);
return 1;
}
int main(void) {
struct mg_context *ctx;
struct mg_callbacks callbacks;
const char *options[] = { "listening_ports", "8080", NULL };
memset(&callbacks, 0, sizeof(callbacks));
callbacks.begin_request = begin_request_handler;
ctx = mg_start(&callbacks, NULL, options);
getchar();
mg_stop(ctx);
return 0;
}