{"id":19892083,"url":"https://github.com/roteklaue/c-webserver","last_synced_at":"2025-05-02T18:31:36.521Z","repository":{"id":255720943,"uuid":"851885830","full_name":"roteKlaue/c-webserver","owner":"roteKlaue","description":"A simple c webserver implementation","archived":false,"fork":false,"pushed_at":"2024-10-18T00:53:44.000Z","size":324,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-19T13:19:33.021Z","etag":null,"topics":["c","framework","simple","webserver"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/roteKlaue.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}},"created_at":"2024-09-03T21:22:42.000Z","updated_at":"2024-10-18T00:53:48.000Z","dependencies_parsed_at":"2024-10-21T12:47:11.588Z","dependency_job_id":null,"html_url":"https://github.com/roteKlaue/c-webserver","commit_stats":null,"previous_names":["roteklaue/c-webserver"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roteKlaue%2Fc-webserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roteKlaue%2Fc-webserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roteKlaue%2Fc-webserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roteKlaue%2Fc-webserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roteKlaue","download_url":"https://codeload.github.com/roteKlaue/c-webserver/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252088498,"owners_count":21692805,"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","framework","simple","webserver"],"created_at":"2024-11-12T18:21:23.222Z","updated_at":"2025-05-02T18:31:32.586Z","avatar_url":"https://github.com/roteKlaue.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Crest\n\n# Crest Webserver Framework\n\nCrest is a lightweight, simple-to-use webserver framework for building web applications in C. It supports routing, middleware, static hosting, and more, making it a flexible choice for developers who want control over their web server logic.\n\n## Features\n\n- Simple and customizable routing\n- Middleware support\n- Static file hosting\n- JSON and HTML responses\n- Basic error handling\n- Redirects\n\n## Example\n\nHere's a simple example of how to set up a web server using Crest. This server demonstrates various routes, including serving static files, handling POST requests, and sending JSON responses.\n\n### Code\n\n```c\n#include \u003cstdio.h\u003e\n#include \"webserver/webserver.h\"\n\nWebserver *webserver;\n\nvoid index_route(const Request *request, Response *response)\n{\n    send_response(response, \"Hello, World!\");\n}\n\nvoid shutdown_server(const Request *request, Response *response)\n{\n    webserver-\u003econtinue_running = false;\n    printf(\"shutting donw\\n\");\n    send_response(response, \"Shutting down\");\n}\n\nvoid html_test(const Request *request, Response *response)\n{\n    set_content_type(response, HTML);\n    send_response(response, \"\u003cbody\u003e \u003ch1\u003ehuman\u003c/h1\u003e\u003cp\u003esus\u003c/p\u003e \u003c/body\u003e\");\n}\n\nvoid redirect_test(const Request *request, Response *response) {\n    redirect_response(response, \"/\", true);\n}\n\nint main()\n{\n    initialise_webserver_framework();\n    webserver = create_webserver();\n    HashTable *games_router = create_routing_table();\n\n    add_route(webserver-\u003eroutes, Get, \"/\", \u0026index_route);\n    add_route(webserver-\u003eroutes, Get, \"/shutdown\", \u0026shutdown_server);\n    add_route(webserver-\u003eroutes, Get, \"/redirect\", \u0026redirect_test);\n    add_router(webserver-\u003eroutes, \"/games\", games_router);\n\n    add_route(games_router, Get, \"/\", \u0026html_test);\n    add_route(games_router, Get, \"/index\", \u0026html_test);\n    add_route(games_router, Get, \"/index.html\", \u0026html_test);\n    \n    run_webserver(webserver);\n    clean_up_webserver(webserver);\n    clean_up_webserver_framework();\n\n    return 0;\n}\n```\n\n## Building and Running\n\n 1. Clone the repository.\n 2. Include the necessary files from the `webserver` directory.\n 3. Compile the project:\n    `gcc -o webserver main.c webserver/*.c`\n 4. Run the webserver `./webserver`\n 5. Access the web server at http://localhost:4096 (Default PORT is 4096).\n\n## Contributing\n\nFeel free to fork and submit pull requests to improve the framework. Any contributions are welcome!\n\n## License\n\nThis project is licensed under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froteklaue%2Fc-webserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froteklaue%2Fc-webserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froteklaue%2Fc-webserver/lists"}