{"id":15986288,"url":"https://github.com/ncordon/files-web-server","last_synced_at":"2025-07-20T09:03:00.086Z","repository":{"id":73916508,"uuid":"186186587","full_name":"ncordon/files-web-server","owner":"ncordon","description":"Test of a C++ web server to index folders","archived":false,"fork":false,"pushed_at":"2019-05-13T10:07:15.000Z","size":44,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-10T06:14:41.922Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ncordon.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":"2019-05-11T22:21:34.000Z","updated_at":"2021-08-31T01:40:55.000Z","dependencies_parsed_at":"2023-09-21T13:36:13.674Z","dependency_job_id":null,"html_url":"https://github.com/ncordon/files-web-server","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncordon%2Ffiles-web-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncordon%2Ffiles-web-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncordon%2Ffiles-web-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ncordon%2Ffiles-web-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ncordon","download_url":"https://codeload.github.com/ncordon/files-web-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247251569,"owners_count":20908530,"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":[],"created_at":"2024-10-08T02:44:02.704Z","updated_at":"2025-04-04T21:28:50.381Z","avatar_url":"https://github.com/ncordon.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# File indexer\n\nIt works under Linux. It has not been tested on Windows.\n\n# Compilation\n\nIt suffices to do:\n\n```bash\nmkdir bin obj\nmake\n```\n\n# Test\n\nFrom one terminal, we should do, once compiled:\n\n```bash\n./bin/file-indexer 8000 .\n```\n\nThis would mount this folder in the 8000 port. We have a test file named `requests` into this directory. To test the concurrent requests it contains, we should do, from another terminal:\n\n```bash\ncat requests | while read n; do printf \"%q\\n\" \"$n\"; done | xargs -P 4 -I % bash -c %\n```\n\nThis last test generates 4 concurrent requests, whose result will sometimes be unordered. An example:\n\n```\n\u003c!DOCTYPE html\u003e \n\u003chtml\u003e \n\u003cbody\u003e \n\u003cpre\u003e \n\u003c!DOCTYPE html\u003e \n\u003chtml\u003e \n\u003cbody\u003e \n\u003cpre\u003e \n#ifndef FILE__H\n#define FILE__H\n\n#include \u003cstring\u003e\n#include \u003cvector\u003e\n#include \u003cdirent.h\u003e\n#include \u003csys/stat.h\u003e\n\nusing std::string;\nusing std::vector;\n\nclass File {\nprivate: \n  string path;\n  \npublic:  \n  File(string path);\n  \n  bool is_file();\n  \n  bool is_folder();\n  \n  vector\u003cstring\u003e list_files();\n  \n  File operator /(string file);\n  \n  string get_path() {\n    return path;\n  }\n};\n\n#endif\n#ifndef SERVER__H\n#define SERVER__H\n\n#include \u003cunistd.h\u003e \n#include \u003ccstdlib\u003e \n#include \u003cstring\u003e\n#include \u003cvector\u003e\n#include \u003cfstream\u003e\n#include \u003csys/types.h\u003e\n#include \u003csys/socket.h\u003e\n#include \u003cnetinet/in.h\u003e\n#include \u003cfcntl.h\u003e\n#include \u003ciostream\u003e\n#include \"file.h\"\n#define BACKLOG 5\n\nusing std::string;\nusing std::vector;\nusing std::ifstream;\nusing std::cout;\nusing std::endl;\n\nstruct HttpResponses {\n  string NOT_FOUND();\n\n  string OK(string msg);\n};\n\nclass Request {\nprivate:\n  int fd;\n  string root_folder;\n  const int BUFFER_SIZE = 1024;\n  HttpResponses responses;\n  \npublic:\n  Request(string root_folder, int fd);\n  \n  void answer();\n};\n\nclass FileServer {\nprivate: \n  int socket_fd;\n  string root_folder;\n  \npublic:\n  FileServer(int port, string root_folder);\n  \n  Request await_request();\n};\n\n#endif\n\n\u003c/pre\u003e \n\u003c/body\u003e \n\u003c!DOCTYPE html\u003e \n\u003chtml\u003e \n  \u003cbody\u003e \n    \u003ch1\u003e Not Found \u003c/h1\u003e \n  \u003c/body\u003e \n\n\u003c/pre\u003e \n\u003c/body\u003e \n\u003c/html\u003e \n\u003c/html\u003e\u003c/html\u003e\u003c!DOCTYPE html\u003e \n\u003chtml\u003e \n  \u003cbody\u003e \n    \u003ch1\u003e Not Found \u003c/h1\u003e \n  \u003c/body\u003e \n\u003c/html\u003e\n```\n\n![localhost-example](./imgs/localhost-example.png)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fncordon%2Ffiles-web-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fncordon%2Ffiles-web-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fncordon%2Ffiles-web-server/lists"}