Advertisement
Guest User

Untitled

a guest
Nov 15th, 2015
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.93 KB | None | 0 0
  1. #include "microhttpd.h"
  2. #include <stdio.h>
  3.  
  4. #define PORT 8080
  5.  
  6. static int answer_to_connection(void *cls, struct MHD_Connection *connection, const char *url, const char *method,
  7.                                 const char *version, const char *upload_data, size_t *upload_data_size,
  8.                                 void **con_cls) {
  9.     const char *page = "<html><body>Hello world</body></html>";
  10.     struct MHD_Response *response;
  11.     int ret;
  12.     response = MHD_create_response_from_buffer(strlen(page), (void *) page, MHD_RESPMEM_PERSISTENT);
  13.     ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
  14.     MHD_destroy_response(response);
  15.     return ret;
  16. }
  17.  
  18. int main() {
  19.     struct MHD_Daemon *daemon;
  20.     daemon = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY, PORT, NULL, NULL, &answer_to_connection, NULL, MHD_OPTION_END);
  21.     if (NULL == daemon)
  22.         return 1;
  23.     getchar();
  24.     MHD_stop_daemon(daemon);
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement