{"id":28403047,"url":"https://github.com/perikiyoxd/webserver","last_synced_at":"2025-10-26T14:35:15.396Z","repository":{"id":258733718,"uuid":"874504433","full_name":"PerikiyoXD/WebServer","owner":"PerikiyoXD","description":"A sample implementation of a C++ Web Server","archived":false,"fork":false,"pushed_at":"2024-10-18T00:37:23.000Z","size":8,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-26T17:51:27.514Z","etag":null,"topics":["cpp","xmake-built"],"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/PerikiyoXD.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":"2024-10-18T00:26:33.000Z","updated_at":"2024-10-18T00:37:37.000Z","dependencies_parsed_at":null,"dependency_job_id":"e693b534-d470-4370-875b-b11342425f51","html_url":"https://github.com/PerikiyoXD/WebServer","commit_stats":null,"previous_names":["perikiyoxd/webserver"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/PerikiyoXD/WebServer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerikiyoXD%2FWebServer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerikiyoXD%2FWebServer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerikiyoXD%2FWebServer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerikiyoXD%2FWebServer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PerikiyoXD","download_url":"https://codeload.github.com/PerikiyoXD/WebServer/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerikiyoXD%2FWebServer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268500608,"owners_count":24260163,"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-08-03T02:00:12.545Z","response_time":2577,"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":["cpp","xmake-built"],"created_at":"2025-06-01T16:36:39.908Z","updated_at":"2025-10-26T14:35:10.169Z","avatar_url":"https://github.com/PerikiyoXD.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# C++ Web Server with Route Management and File Provider\n\nThis is a simple multithreaded web server implemented in C++ using the Asio library. It supports basic route management, logging (similar to Nginx access logs), and secure file serving from a designated folder.\n\n## Features\n\n- **Route management**: Define custom routes that respond to specific HTTP requests.\n- **File provider**: Serve static files from a folder (`/public` by default) with proper path sanitization to prevent directory traversal attacks.\n- **Logging**: Logs HTTP requests in the Nginx-style access log format, with both console and file logging.\n- **Multithreading**: Each request is handled in a separate thread to improve performance.\n\n## Dependencies\n\n- **Xmake** build system\n- **C++17** or later\n- [Asio](https://think-async.com/Asio/) (provided by xmake)\n\n## Getting Started\n\n### 1. Clone the Repository\n\n```bash\ngit clone \u003crepository-url\u003e\ncd \u003crepository-folder\u003e\n```\n\n### 2. Build the Project with Xmake\n\n#### Install Xmake\n\nIf you don't have Xmake installed, you can install it by following the instructions from the [Xmake website](https://xmake.io/#/).\n\n#### Build the Project\n\nAfter installing Xmake, you can build the project by running:\n\n```bash\nxmake\n```\n\nThis will compile the project and generate the executable in the `build` directory.\n\n### 4. Run the Server\n\nOnce the project is built, run the server:\n\n```bash\nxmake run WebServer\n```\n\nThe server will start listening on port `8080` by default. You can access it via `http://localhost:8080`.\n\n### 5. Accessing Routes\n\n- `/` - Responds with a welcome message: \"Welcome to the homepage!\"\n- `/about` - Responds with \"This is the about page.\"\n- `/public/*` - Serves static files located in the `./public` folder. Example: `http://localhost:8080/public/file.txt`.\n\n### 6. Logging\n\nLogs are saved in an `access.log` file in the project root directory. Logs follow the Nginx access log style:\n\n```\n\u003cclient-ip\u003e - - [timestamp] \"GET \u003croute\u003e\" \u003cstatus\u003e\n```\n\nExample:\n\n```\n127.0.0.1 - - [18/Oct/2024:14:32:45 +0000] \"GET /about\" 200 OK\n```\n\n## Adding Routes\n\nYou can define your own custom routes in the `main()` function:\n\n```cpp\nserver.addRoute(\"/custom\", []() {\n    return \"This is a custom route!\";\n});\n```\n\n### Serving Files\n\nTo serve files securely, define a route prefix (like `/public`) and a folder to serve files from. For example:\n\n```cpp\nserver.addFileProviderRoute(\"/public\", \"./public\");\n```\n\nThis will serve files located in the `./public` folder at the URL `/public/\u003cfilename\u003e`.\n\n## License\n\nThis project is open-source and licensed under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperikiyoxd%2Fwebserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperikiyoxd%2Fwebserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperikiyoxd%2Fwebserver/lists"}