{"id":28964533,"url":"https://github.com/kickhead13/ptt.h","last_synced_at":"2025-06-24T05:06:54.092Z","repository":{"id":300757727,"uuid":"1005846002","full_name":"kickhead13/ptt.h","owner":"kickhead13","description":"A compact and easy-to-use HTTP C library for the web.","archived":false,"fork":false,"pushed_at":"2025-06-23T12:23:39.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-23T13:20:50.003Z","etag":null,"topics":["c","http","http-server","web-library"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kickhead13.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-20T23:48:12.000Z","updated_at":"2025-06-23T12:23:42.000Z","dependencies_parsed_at":"2025-06-23T13:33:22.136Z","dependency_job_id":null,"html_url":"https://github.com/kickhead13/ptt.h","commit_stats":null,"previous_names":["kickhead13/ptt.h"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kickhead13/ptt.h","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kickhead13%2Fptt.h","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kickhead13%2Fptt.h/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kickhead13%2Fptt.h/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kickhead13%2Fptt.h/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kickhead13","download_url":"https://codeload.github.com/kickhead13/ptt.h/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kickhead13%2Fptt.h/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261611074,"owners_count":23184020,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","http","http-server","web-library"],"created_at":"2025-06-24T05:06:41.264Z","updated_at":"2025-06-24T05:06:54.076Z","avatar_url":"https://github.com/kickhead13.png","language":"C","readme":"# ptt.h\n\n\u003e [!WARNING]\n\u003e This library is NOT production ready (yet). Please only use it for fun. :)\n\n## Description\n`ptt.h` is a simple and easy-to-use HTTP library for C, that will get you past the boredom of initial setups and right into implementing web services... (currently under developement).\n\n## Examples\nA simple server that on GET requests to /example responds with a HTML page that displays a friendly message and a button :).\n\n```c\n#include \"ptt.h\"\n#include \u003cunistd.h\u003e\n\nptth_response_t get_func(ptth_request_t _, ptth_shared_t *__) {\n  PTTH_RESPONDE_HTML(\n    \"\u003c!DOCTYPE html\u003e\"\n    \"\u003chead\u003e\u003c/head\u003e\"\n    \"\u003cbody\u003e\"\n    \"HI! :)\"\n    \"\u003cbutton\u003eCLICK ME!\u003c/button\u003e\"\n    \"\u003c/body\u003e\")\n}\n\nint main() {\n  ptth_server_t server;\n  ptth_init_server(\u0026server);\n  ptth_add_service(\u0026server, PTTH_GET, \"/example\", \u0026get_func);\n  ptth_bind_server(\u0026server, \"127.0.0.1\", 8081);\n  ptth_start(server);\n}\n```\nYou're endpoints don't have to be static, you can set up variable names for URL segments and retrieve them at run time. Here is an example where when you access `/hi/\u003cname\u003e/` the web server will display the message `\"Hi, \u003cname\u003e! :3\"` in the browser.\n```c\n#include \"ptt.h\"\n#include \u003cunistd.h\u003e\n\nptth_response_t get_func(ptth_request_t req, ptth_shared_t *__) {\n  char *test = ptth_map_get_value(*(req.mpath), \"var_name\");\n  char message[100];\n  message[0] = '\\0';\n  strcat(message, \"Hi, \");\n  strcat(message, test);\n  strcat(message, \"! :3\");\n  PTTH_RESPONDE_HTML(message)\n}\n\nint main() {\n  ptth_server_t server;\n  ptth_init_server(\u0026server);\n  ptth_add_service(\u0026server, PTTH_GET, \"/hi/{var_name}/\", \u0026get_func);\n  ptth_bind_server(\u0026server, \"127.0.0.1\", 8081);\n  ptth_start(server);\n}\n```\nHere is what the browser displays:\u003cbr\u003e\n![example_hi](./plus/hi_alex.png)\n\n## Installation and Usage\nTo install and use ptt.h you should simply clone this repository and copy the header in your working directory.\n\n```sh \n $ git clone 'https://github.com/kickhead/ptt.h.git'\n $ cp ./ptt.h/ptt.h ./../myWorkingDir\n```\nAfter that you can use it as any other header library... include it in your porjects :).\n```c \n#include \"ptt.h\"\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkickhead13%2Fptt.h","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkickhead13%2Fptt.h","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkickhead13%2Fptt.h/lists"}