Skip to content
/ tpee Public

Latest commit

 

History

28 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

tpee

A low-key HTTP micro-framework for people who hate web bloat

Installation

git clone git@soophie.de:/srv/git/tpee
cd http
sudo make install

Quick Start

#define SO_TPEE_IMPL
#include <tpee.h>

#define HOST "0.0.0.0"
#define PORT 80

TPEE_GET("/", index_page) {
  (void) req;
  tpee_resp_t resp = tpee_resp_create(TPEE_STATUS_OK);
  tpee_resp_header(&resp, "Content-Type", "text/html");
  char *html = "<h1>Hello, World!</h1>";
  tpee_resp_body(&resp, html, strlen(html));
  return resp;
}

int main(void) {
  tpee_t *tpee = tpee_init();
  tpee_err_t err = tpee_bind_listen(tpee, HOST, PORT);
  if (err == TPEE_ERR_OK) {
    printf("server is running on %s:%d\n", HOST, PORT);
    pause();
    tpee_close(tpee);
  }
  else {
    printf("failed to start server on %s:%d\n", HOST, PORT);
  }
  printf("server stopped\n");
  tpee_cleanup(tpee);
  return 0;
}

Compiling

cc -o main -lssl -lcrypto -lpthread main.c

About

A low-key HTTP micro-framework for people who hate web bloat

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages