{"id":19963878,"url":"https://github.com/thefcraft/c-http-server","last_synced_at":"2025-10-29T02:03:53.319Z","repository":{"id":231723235,"uuid":"782381687","full_name":"thefcraft/c-http-server","owner":"thefcraft","description":"Basic http server in c","archived":false,"fork":false,"pushed_at":"2025-01-27T14:43:11.000Z","size":11688,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-07-01T00:04:07.800Z","etag":null,"topics":["c-http-server","http-server-library","websocket"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thefcraft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-04-05T07:31:24.000Z","updated_at":"2025-01-27T14:43:14.000Z","dependencies_parsed_at":"2025-07-01T00:14:11.014Z","dependency_job_id":null,"html_url":"https://github.com/thefcraft/c-http-server","commit_stats":null,"previous_names":["thefcraft/c-http-server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/thefcraft/c-http-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thefcraft%2Fc-http-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thefcraft%2Fc-http-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thefcraft%2Fc-http-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thefcraft%2Fc-http-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thefcraft","download_url":"https://codeload.github.com/thefcraft/c-http-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thefcraft%2Fc-http-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281544194,"owners_count":26519554,"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","status":"online","status_checked_at":"2025-10-29T02:00:06.901Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-server","http-server-library","websocket"],"created_at":"2024-11-13T02:17:46.367Z","updated_at":"2025-10-29T02:03:53.289Z","avatar_url":"https://github.com/thefcraft.png","language":"C","readme":"# Basic HTTP Server in C\n\nA lightweight and efficient HTTP server implementation in C that supports basic routing, static file serving, and both GET and POST requests. This server is designed for development and learning purposes.\n\n## Features\n\n- Simple and clean API inspired by modern web frameworks\n- Support for both GET and POST requests\n- Static file serving capability\n- Route patterns with wildcard support (`/path/*`)\n- Cross-platform compatibility (Windows and Linux)\n- Built-in debugging mode\n- Memory-efficient string and list implementations\n- Support for serving various content types (HTML, JSON, images, etc.)\n- Basic request and response handling\n\n## Prerequisites\n\n### Windows\n- GCC compiler (MinGW)\n- ws2_32 library (Windows Sockets 2)\n\n### Linux\n- GCC compiler\n- Standard C libraries\n\n## Building the Library\n\n### Windows\n```bash\nrm -f libserver.a \u0026\u0026 gcc -c server.c -o server.o -lws2_32 \u0026\u0026 gcc -shared -o server.dll server.o -lws2_32\n```\n\n### Linux\n```bash\ngcc -c server.c \u0026\u0026 ar rcs libserver.a server.o\n```\n## Compilation and Running\n\n### Windows\n```bash\ngcc demo.c -L. -lserver \u0026\u0026 ./a.exe\n```\n\n### Linux\n```bash\ngcc demo.c -L. -lserver \u0026\u0026 ./a.out\n```\n\n## Usage Example\n\nHere's a basic example showing how to create a simple web server:\n\n```c\n#include \u003cstring.h\u003e\n#include \u003cstdlib.h\u003e\n#include \"server.h\"\n\n#define HOST \"0.0.0.0\"\n#define PORT 8080\n#define DEBUG 1\n\n// Route handler for home page\nvoid home(server *self, str *response, list *headers, str *content_buffer) {\n    send_file(response, \"templates/demo.html\");\n}\n\n// Route handler for API endpoint\nvoid api(server *self, str *response, list *headers, str *content_buffer) {\n    response-\u003eappend(response, \"HTTP/1.1 200 OK\\r\\nContent-Type: application/json\\r\\n\\r\\n\");\n    response-\u003eappend(response, \"{\\\"status\\\": \\\"success\\\"}\");\n}\n\nint main() {\n    server app = http_server();\n    \n    // Define routes\n    app.route(\u0026app, \"GET\", \"/\", home);\n    app.route(\u0026app, \"POST\", \"/api\", api);\n    \n    // Start the server\n    app.run(\u0026app, HOST, PORT, DEBUG);\n    return 0;\n}\n```\n\n## API Reference\n\n### Server Functions\n\n- `http_server()`: Creates a new server instance\n- `server.route(server*, method, path, callback)`: Registers a new route\n- `server.run(server*, host, port, debug)`: Starts the server\n- `server.stop(server*)`: Stops the server gracefully\n\n### Utility Functions\n\n- `send_file(str *response, char *filename)`: Sends a file as response\n- `send_file_with_header(str *response, char *filename, char *header)`: Sends a file with custom headers\n\n### String and List Operations\n\nThe server includes custom implementations for string and list operations:\n- `String()`: Creates a new string buffer\n- `List()`: Creates a new list for header storage\n\n## Route Patterns\n\nThe server supports two types of route patterns:\n1. Exact matches: `/path`\n2. Wildcard patterns: `/path/*`\n\n## Debug Mode\n\nWhen debug mode is enabled (`DEBUG=1`), the server will output:\n- Client connection details\n- Request information\n- Response status codes\n- Error messages\n\n## Limitations\n\n- Development server only - not recommended for production use\n- Basic HTTP/1.1 implementation\n- Limited security features\n- No SSL/TLS support\n- Single-threaded operation\n\n## Contributing\n\nFeel free to submit issues, fork the repository, and create pull requests for any improvements.\n\n## Acknowledgments\n\nThis server implementation is designed for educational purposes and as a learning tool for understanding HTTP servers and network programming in C.\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthefcraft%2Fc-http-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthefcraft%2Fc-http-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthefcraft%2Fc-http-server/lists"}