{"id":20940853,"url":"https://github.com/timhanewich/py-server-example","last_synced_at":"2025-07-11T11:35:41.868Z","repository":{"id":217696589,"uuid":"744585225","full_name":"TimHanewich/py-server-example","owner":"TimHanewich","description":"Barebones code example for setting up an HTTP server in Python, running on a Linux-based Raspberry Pi","archived":false,"fork":false,"pushed_at":"2024-01-20T22:01:18.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-13T03:41:21.397Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/TimHanewich.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"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-01-17T15:47:54.000Z","updated_at":"2024-01-17T15:52:51.000Z","dependencies_parsed_at":"2024-01-20T02:04:46.180Z","dependency_job_id":"99bbcc8f-265c-411a-b519-0a2ed25c16ae","html_url":"https://github.com/TimHanewich/py-server-example","commit_stats":null,"previous_names":["timhanewich/py-server-example"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TimHanewich/py-server-example","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimHanewich%2Fpy-server-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimHanewich%2Fpy-server-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimHanewich%2Fpy-server-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimHanewich%2Fpy-server-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TimHanewich","download_url":"https://codeload.github.com/TimHanewich/py-server-example/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TimHanewich%2Fpy-server-example/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264795838,"owners_count":23665241,"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-11-18T23:12:07.410Z","updated_at":"2025-07-11T11:35:41.840Z","avatar_url":"https://github.com/TimHanewich.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Minimalistic Python Server Code\nThis repo contains an example of the basic, boilerplate code for a Python-based HTTP server. The server was coded on and designed to run on a Linux-based Raspberry Pi (Raspberry Pi Zero W to be specific), but can be extrapolated to run on almost any OS-based device.\n\nThe server code can be found in the [server.py](./server.py) module.\n\n[This learing resource](https://realpython.com/python-sockets/) was used for learning as I made this.\n\n## Making Requests\nWhen the server is running, the client will need to make HTTP requests to the server using both the server device's local IP address **and** port number it is listening on. For example:\n\n![example request](https://i.imgur.com/yEQI3HN.png)\n\nIn the above example, HTTP requests are being made through Postman, directing the requests at the server's local IP address, followed by a colon, and the port number the server is listening on (configured in the server code).\n\nIf you instead want to simply *only* want to have to specify the server's IP address and *not* a port number, you simply need to run the server on the HTTP-dedicated port, **port 80**. But, running it on a \"privileged\" port, ports between 0 and 1023, will require `sudo` or `root` privileges to run and begin listening on.\n\n## Running Server in Background After SSH Exited\nWhen you SSH into your server and start the server `.py` script, if you run it in the background with `\u0026` at the end of the command but then exit the SSH session, it will stop. Run this command:\n\n```\nsudo nohup python sever.py \u0026\n```\n\n- `sudo` - will need to add this if your server is on a privileged port (port 80 for HTTP, for example).\n- `nohup` - process will not be killed when you exit the SSH session (is independent of the SSH session).\n- `\u0026` - run in background.\n\nAnd then, to see the process, you can run:\n\n```\nps aux | grep python\n```\n\n`ps aux` lists background tasks. `grep python` filters to tasks with \"python\" in them, showing you your sever process.\n\nTo kill the process, run `kill \u003cprocess number\u003e`. So if it was process number 3407, run `kill 3407`.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimhanewich%2Fpy-server-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimhanewich%2Fpy-server-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimhanewich%2Fpy-server-example/lists"}