hello_world.c
Go to the documentation of this file.
00001 // Copyright (c) 2014 Cesanta Software
00002 // All rights reserved
00003 //
00004 // This example demostrates basic use of Mongoose embedded web server.
00005 // $Date: 2014-09-09 22:20:23 UTC $
00006 
00007 #include <stdio.h>
00008 #include <string.h>
00009 #include "mongoose.h"
00010 
00011 static int ev_handler(struct mg_connection *conn, enum mg_event ev) {
00012   switch (ev) {
00013     case MG_AUTH: return MG_TRUE;
00014     case MG_REQUEST:
00015       mg_printf_data(conn, "Hello! Requested URI is [%s]", conn->uri);
00016       return MG_TRUE;
00017     default: return MG_FALSE;
00018   }
00019 }
00020 
00021 int main(void) {
00022   struct mg_server *server;
00023 
00024   // Create and configure the server
00025   server = mg_create_server(NULL, ev_handler);
00026   mg_set_option(server, "listening_port", "8080");
00027 
00028   // Serve request. Hit Ctrl-C to terminate the program
00029   printf("Starting on port %s\n", mg_get_option(server, "listening_port"));
00030   for (;;) {
00031     mg_poll_server(server, 1000);
00032   }
00033 
00034   // Cleanup, and free server instance
00035   mg_destroy_server(&server);
00036 
00037   return 0;
00038 }


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:04