{"id":22825882,"url":"https://github.com/bylothink/hashmaps-webserver","last_synced_at":"2026-04-21T09:33:08.818Z","repository":{"id":129948913,"uuid":"475195664","full_name":"Bylothink/hashmaps-webserver","owner":"Bylothink","description":"🗺️ A simple web server that provides a RESTful API to store and retrieve data from hashmap data structures made from scratch.","archived":false,"fork":false,"pushed_at":"2022-04-04T23:17:45.000Z","size":100,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-20T10:27:26.387Z","etag":null,"topics":["docker","hashmaps","jwt","python","web-server"],"latest_commit_sha":null,"homepage":"","language":"Python","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/Bylothink.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":"2022-03-28T22:14:25.000Z","updated_at":"2023-10-16T13:49:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"fe46de30-9fe1-4b01-b9d4-5d44e6194b88","html_url":"https://github.com/Bylothink/hashmaps-webserver","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Bylothink/hashmaps-webserver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bylothink%2Fhashmaps-webserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bylothink%2Fhashmaps-webserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bylothink%2Fhashmaps-webserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bylothink%2Fhashmaps-webserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bylothink","download_url":"https://codeload.github.com/Bylothink/hashmaps-webserver/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bylothink%2Fhashmaps-webserver/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32085518,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-21T06:27:27.065Z","status":"ssl_error","status_checked_at":"2026-04-21T06:27:21.250Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["docker","hashmaps","jwt","python","web-server"],"created_at":"2024-12-12T17:12:23.560Z","updated_at":"2026-04-21T09:33:08.790Z","avatar_url":"https://github.com/Bylothink.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HashMaps web server 🗺\n\nA simple web server that provides a RESTful API to store and\nretrieve data from hashmap data structures made from scratch.\n\nIt provides a collection of different hashmaps for each authenticated user.  \nAuthentication is done by using the **[JSON Web Token](https://jwt.io/)** standard.\n\nIt stores the data in files on the disk and persists it across restarts.\n\nIt also keeps track via a simple log file of all the requests made by users,\nallowing subsequent analysis and statistical processing of the use.\n\n## Requirements\n\n- **[`Python`](https://www.python.org/downloads/)**\n- **[`pip`](https://pypi.org/project/pip/)**\n- **[`Pipenv`](https://pipenv.pypa.io/en/latest/)**\n\n*... or...*\n\n- **[`Docker`](https://www.docker.com/)**\n- **[`Docker Compose`](https://docs.docker.com/compose/)**\n\n## Installation / Build\n\n### Using your local Python\n\nMake sure you have `Python`, `pip`, and `Pipenv` installed on your machine.  \nOnce done, navigate to your project folder and type the following command:\n\n```sh\npipenv install --dev --three\n```\n\n\u003e *This will install all the dependencies required from this project to run properly.*\n\n### Using Docker\n\nMake sure you have `Docker` installed on your machine and the `Dockerd` service is up \u0026 running.  \nOnce done, navigate to your project folder and type the following command:\n\n```sh\ndocker-compose build\n```\n\n\u003e *This will build the `Docker` image which will later be used to run the project.*\n\n## Configuration\n\nBefore starting the server, you need to configure it.\n\n### `.env` file\n\nTo do so, you need to create a `.env` file in the project folder like the following:\n```\nSECRET_KEY=\u003c32_chars_random_string\u003e\n```\n\n\u003e *This `SECRET_KEY` value will be the secret you need to use to*\n\u003e *generate your `JWT token` used for the user authentication.*\n\n#### **N.B.:**\n\u003e If you're having some kind of problem related to the `SECRET_KEY`\n\u003e  environmental variable, you can also force the export in your console as below:\n\u003e  \n\u003e ```sh\n\u003e export SECRET_KEY=\u003c32_chars_random_string\u003e\n\u003e ```\n\n### `JWT token`\n\nAs just mentioned, the `JWT token` is used to authenticate the user.  \nFor this reason, you need to create your own `JWT token` if you want to use this service.\n\nVisit the following URL: **[jwt.io](https://jwt.io/)**  \nWe will work on the right side of the page, the \"**Decoded**\" section.\n\nPaste the same `SECRET_KEY` you just wrote inside the `.env`\ninto the input box that shows \"`your-256-bit-secret`\".  \nNext, edit the \"**PAYLOAD**\" section by replacing the content with the following:\n\n```json\n{ \"username\": \"\u003cchoose-the-username-you-want-to-use\u003e\" }\n```\n\n\u003e *Choose your favourite username or change it with some others if you want to try the multi-user experience.*\n\nNow you can save the newly generated `JWT token`, shown on the left side of the screen, under the \"**Encoded**\" section.  \nIt should look almost like...\n\n```\neyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c\n```\n\n## Starting the server\n\n### Using your local Python\n\nType the following command:\n\n```sh\npipenv shell\n\ncd src/\n\nmkdir -p .volume/collections \\\n         .volume/logs\n\npython3 run.py\n```\n\n\u003e *This will also run the project in `DEBUG` mode, by default.*\n\n### Using Docker\n\nType the following command:\n\n```sh\ndocker-compose up\n```\n\n\u003e *This will also run the project in `PRODUCTION` mode, by default.*\n\n## That's it!\n\nNow the web server is running and you can access it at the following URL:\n\n- **[localhost:8000](http://localhost:8000/)**\n\n### Authentication\n\nAll you have to do now is to append to your requests the `Authorization` header\nvalued with the `JWT token` you previously generated using the `SECRET_KET`.\n\n### Requests\n\nThe web server provide the following endpoints:\n\n- **`/`**\n    - **GET**: returns the entire collection of hashmaps of the authenticated user.\n- **`/\u003cname\u003e`**\n    - **GET**: returns the `\u003cname\u003e` hashmap with all the stored key-value pairs.\n    - **POST**: creates the `\u003cname\u003e` hashmap if it doesn't exist yet.  \n    Ignores the request payload.\n    - **PUT**: renames the `\u003cname\u003e` hashmap using the value present in the request payload.\n    - **DELETE**: removes the `\u003cname\u003e` hashmap if it already exists.  \n    Ignores the request payload.\n- **`/\u003cname\u003e/\u003ckey\u003e`**\n    - **GET**: returns the value for `\u003ckey\u003e` stored within the `\u003cname\u003e` hashmap.\n    - **POST**: creates and sets the value for `\u003ckey\u003e` stored within the\n    `\u003cname\u003e` hashmap using the value present in the request payload.  \n    It fails if `\u003ckey\u003e` already exists.\n    - **PUT**: replaces the value for `\u003ckey\u003e` stored within the\n    `\u003cname\u003e` hashmap using the value present in the request payload.  \n    It fails if `\u003ckey\u003e` doesn't exist yet.\n    - **DELETE**: removes the value for `\u003ckey\u003e` stored within the `\u003cname\u003e` hashmap.  \n    Ignores the request payload.\n\n#### **N.B.:**\n\u003e The request payload is read as `text/plain`.  \n\u003e No `application/x-www-form-urlencoded`, `application/json` or `multipart/form-data` are currently supported.\n\n## Personal notes\n\n- If you choose to use `Docker` it will be much faster \u0026 easier to get the project up \u0026 running.\n- I've chosen to use as little as possible the built-in `dict` data structure to make it more \"challenging\".  \nSadly, in some cases, I preferred to use `dict`, thus avoiding rewriting the entire JSON parser. 😅  \nWhere was possible, instead of using JSON, I used CSV format to avoid using `dict`.\n- It isn't thread-safe yet, so you should use it **ONLY** in a single-threaded environment.\n- Right now, due to using an username slug to handle the collections,\nit might happen that two different usernames (with some weird\nand usually not allowed characters) collide to the same slug. I know.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbylothink%2Fhashmaps-webserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbylothink%2Fhashmaps-webserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbylothink%2Fhashmaps-webserver/lists"}