... POST ...
... GET ...
... POST ...
const PORT = 8080;
var http = require('http');
var body = '<html><head><title>Hello world</title></head><body>Hello world</body></html>';
http.createServer(function (req, res) {
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(body);
}).listen(PORT);
console.log('Server is running on port ' + PORT);
#include <string.h>
#include <stdio.h>
#define PORT 8080
#define PAGE "<html><head><title>Hello world</title></head><body>Hello world</body></html>"
static struct MHD_Response *response;
static int ahc_echo(void *cls, struct MHD_Connection *connection, const char *url, const char *method,
const char *version, const char *upload_data, size_t *upload_data_size, void **ptr) {
return MHD_queue_response(connection, MHD_HTTP_OK, response);
}
int main(int argc, char *const *argv) {
struct MHD_Daemon *d;
response = MHD_create_response_from_buffer(strlen(PAGE), (void *) PAGE, MHD_RESPMEM_PERSISTENT);
(void) MHD_add_response_header(response, MHD_HTTP_HEADER_CONNECTION, "keep-alive");
(void) MHD_add_response_header(response, MHD_HTTP_HEADER_CONTENT_TYPE, "text/html");
d = MHD_start_daemon(MHD_USE_SELECT_INTERNALLY,
PORT, NULL, NULL, &ahc_echo, NULL,
MHD_OPTION_END);
if (d == NULL)
return 1;
printf("Server is running on port %d", PORT);
getchar();
MHD_stop_daemon(d);
MHD_destroy_response(response);
return 0;
}