{"id":25456408,"url":"https://github.com/icarogabryel/simple-http-like-server","last_synced_at":"2025-05-16T18:11:07.811Z","repository":{"id":275241900,"uuid":"925507723","full_name":"icarogabryel/simple-http-like-server","owner":"icarogabryel","description":"Simple HTTP-like server written in Python and build over TCP sockets. It uses a minimalistic custom version of the HTTP protocol.","archived":false,"fork":false,"pushed_at":"2025-02-09T02:19:45.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-18T01:40:21.234Z","etag":null,"topics":["http","http-server","protocol","requests","server"],"latest_commit_sha":null,"homepage":"","language":"Python","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/icarogabryel.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":"2025-02-01T03:09:22.000Z","updated_at":"2025-02-09T02:19:48.000Z","dependencies_parsed_at":"2025-02-18T01:38:31.022Z","dependency_job_id":"a7acd22f-a704-4f97-bdd4-06b7d728625f","html_url":"https://github.com/icarogabryel/simple-http-like-server","commit_stats":null,"previous_names":["icarogabryel/simple-http-server","icarogabryel/simple-http-like-server"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icarogabryel%2Fsimple-http-like-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icarogabryel%2Fsimple-http-like-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icarogabryel%2Fsimple-http-like-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/icarogabryel%2Fsimple-http-like-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/icarogabryel","download_url":"https://codeload.github.com/icarogabryel/simple-http-like-server/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254582907,"owners_count":22095518,"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":["http","http-server","protocol","requests","server"],"created_at":"2025-02-18T01:38:26.000Z","updated_at":"2025-05-16T18:11:07.792Z","avatar_url":"https://github.com/icarogabryel.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple HTTP-Like Server\n\nIn this repo, You will find a simple HTTP-like server written in Python. The server is build over TCP sockets and uses a minimalistic version of the HTTP protocol.\n\n## The Protocol\n\nJust like the HTTP protocol, the server uses a request-response model. Both requests and responses are JSON objects.\n\n\u003cdiv style=\"display: flex; justify-content: center; width: 100%;\"\u003e\n    \u003cdiv style=\"flex: 1; margin-right: 10px;\"\u003e\n        \u003ch3\u003eRequests\u003c/h3\u003e\n        \u003cp\u003eThe requests have the following fields:\u003c/p\u003e\n        \u003cul\u003e\n            \u003cli\u003e\u003ccode\u003emethod\u003c/code\u003e: The HTTP method used in the request. They can be GET, POST, PUT and DELETE.\u003c/li\u003e\n            \u003cli\u003e\u003ccode\u003epath\u003c/code\u003e: The path of the requested resource.\u003c/li\u003e\n            \u003cli\u003e\u003ccode\u003edata\u003c/code\u003e: The data sent in the request body.\u003c/li\u003e\n        \u003c/ul\u003e\n    \u003c/div\u003e\n    \u003cdiv style=\"flex: 1;\"\u003e\n        \u003ch3\u003eResponses\u003c/h3\u003e\n        \u003cp\u003eThe responses have the following fields:\u003c/p\u003e\n        \u003cul\u003e\n            \u003cli\u003e\u003ccode\u003ecode\u003c/code\u003e: The status code of the response.\u003c/li\u003e\n            \u003cli\u003e\u003ccode\u003emessage\u003c/code\u003e: The status message of the response.\u003c/li\u003e\n            \u003cli\u003e\u003ccode\u003edata\u003c/code\u003e: The data sent in the response body.\u003c/li\u003e\n        \u003c/ul\u003e\n    \u003c/div\u003e\n\u003c/div\u003e\n\n## How It Works\n\n1. Server Reception:\n\n    This server uses a TCP socket and listens for incoming connections. When a connection is received, the server reads the incoming data and put it into a buffer. Every received data is added to this buffer until the end marker `\\0` is found. After the end marker is found, the server processes the request. Because the server is stateless, it closes the connection after sending the response.\n\n2. Request Handling:\n\n    The server parses the received data into a JSON object in the `handle` function. Then, it checks if the request is valid. If the request is valid, the server processes it and sends a response. If the request is invalid, the server sends an error response.\n\n3. Response Sending:\n\n    The server sends the response to the client. The response is sent as a JSON object. The server sends the response in the following format:\n\n    ```json\n    {\n        \"code\": 200,\n        \"message\": \"OK\",\n        \"data\": \"Hello, World!\"\n    }\n    ```\n\n## Tests\n\nThe server was tested using the files in the `tests` folder. It was made integration tests, load tests and function tests. This last one is the principal and was made using a series of `assert` statements like below:\n\n```python\n    response = send_message(dumps({'method': 'GET', 'path': '/'}))\n    assert response == dumps({'code': 200, 'message': 'OK', 'data': 'Hello, World!'})\n```\n\n## How to Run\n\nTo run the server, you need to have Python installed on your machine. You can run the server by executing the `main.py` file in the `src` folder following command in your terminal:\n\n```bash\npython main.py\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficarogabryel%2Fsimple-http-like-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ficarogabryel%2Fsimple-http-like-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ficarogabryel%2Fsimple-http-like-server/lists"}