2011-06-18 00:29:46 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include "mongoose.h"
|
|
|
|
|
2013-12-16 13:33:50 +00:00
|
|
|
// This function will be called by mongoose on every new request
|
|
|
|
static int index_html(struct mg_connection *conn) {
|
2014-01-14 12:50:13 +00:00
|
|
|
mg_printf_data(conn, "Hello! Requested URI is [%s]", conn->uri);
|
|
|
|
return 1;
|
2011-06-18 00:29:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(void) {
|
2013-12-16 13:33:50 +00:00
|
|
|
struct mg_server *server;
|
2013-02-01 16:48:30 +00:00
|
|
|
|
2013-12-16 13:33:50 +00:00
|
|
|
// Create and configure the server
|
|
|
|
server = mg_create_server(NULL);
|
|
|
|
mg_set_option(server, "listening_port", "8080");
|
|
|
|
mg_add_uri_handler(server, "/", index_html);
|
2011-06-18 00:29:46 +01:00
|
|
|
|
2013-12-16 13:33:50 +00:00
|
|
|
// Serve request. Hit Ctrl-C to terminate the program
|
|
|
|
printf("Starting on port %s\n", mg_get_option(server, "listening_port"));
|
|
|
|
for (;;) {
|
|
|
|
mg_poll_server(server, 1000);
|
|
|
|
}
|
2013-02-01 16:48:30 +00:00
|
|
|
|
2013-12-16 13:33:50 +00:00
|
|
|
// Cleanup, and free server instance
|
|
|
|
mg_destroy_server(&server);
|
2011-06-18 00:29:46 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|