-
-
Save asim/894267 to your computer and use it in GitHub Desktop.
ignore this
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <event.h> | |
#include <evhttp.h> | |
#include <stdlib.h> | |
struct server { | |
struct event_base *base; | |
struct evhttp *http; | |
}; | |
void on_request(struct evhttp_request *r, void *ctx) { | |
const char *uri = evhttp_request_uri(r); | |
struct server *thing = ctx; | |
int ret; | |
evhttp_send_reply(r, 200, "Hello World", NULL); | |
} | |
int main(int argc, char *argv[]) { | |
struct server *thing = calloc(1, sizeof(struct server)); | |
char host[] = "127.0.0.1"; | |
int port = 8009; | |
thing->base = event_base_new(); | |
thing->http = evhttp_new(thing->base); | |
evhttp_bind_socket(thing->http, host, port); | |
evhttp_set_gencb(thing->http, on_request, thing); | |
event_base_dispatch(thing->base); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment