{"id":15170062,"url":"https://github.com/ishangavidusha/httpserver","last_synced_at":"2026-01-24T10:34:28.515Z","repository":{"id":253250908,"uuid":"842829603","full_name":"ishangavidusha/httpserver","owner":"ishangavidusha","description":"A lightweight, feature-rich HTTP server implementation for MicroPython environments. This server supports basic HTTP methods, CORS and more.","archived":false,"fork":false,"pushed_at":"2024-08-18T06:51:20.000Z","size":15,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-13T17:39:33.847Z","etag":null,"topics":["http","http-server","micropython","micropython-esp32","micropython-esp8266","python","sse"],"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/ishangavidusha.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":"2024-08-15T07:17:57.000Z","updated_at":"2024-08-18T06:51:22.000Z","dependencies_parsed_at":"2025-05-14T21:49:00.708Z","dependency_job_id":null,"html_url":"https://github.com/ishangavidusha/httpserver","commit_stats":{"total_commits":5,"total_committers":1,"mean_commits":5.0,"dds":0.0,"last_synced_commit":"8b20f1f5451e25d52680104613e8b91b0949a67f"},"previous_names":["ishangavidusha/httpserver"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ishangavidusha/httpserver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ishangavidusha%2Fhttpserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ishangavidusha%2Fhttpserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ishangavidusha%2Fhttpserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ishangavidusha%2Fhttpserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ishangavidusha","download_url":"https://codeload.github.com/ishangavidusha/httpserver/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ishangavidusha%2Fhttpserver/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28725374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T10:24:43.181Z","status":"ssl_error","status_checked_at":"2026-01-24T10:24:36.112Z","response_time":89,"last_error":"SSL_read: 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":["http","http-server","micropython","micropython-esp32","micropython-esp8266","python","sse"],"created_at":"2024-09-27T08:00:28.058Z","updated_at":"2026-01-24T10:34:28.488Z","avatar_url":"https://github.com/ishangavidusha.png","language":"Python","readme":"# MicroPython HTTP Server\n\nA lightweight, feature-rich HTTP server implementation for MicroPython environments. This server supports basic HTTP methods, CORS, and more, optimized for single-threaded microcontroller environments.\n\n## Features\n\n- Support for HTTP methods: GET, POST, PUT, DELETE, OPTIONS\n- CORS (Cross-Origin Resource Sharing) support\n- Query parameter parsing\n- JSON request/response handling\n- Static file serving\n- Customizable logging\n- Error handling with custom HTTP errors\n\n## Requirements\n\n- MicroPython environment\n- `socket` and `json` modules (usually included in MicroPython)\n\n## Installation\n\n1. Copy the `server` directory to your MicroPython device.\n2. Create your main application file (e.g., `main.py`) that imports and uses the server.\n\n## Usage\n\nHere's a basic example of how to use the server:\n\n```python\nfrom server.server import HTTPServer, Response, HTTPError\n\nserver = HTTPServer(port=8080, log_level='DEBUG', max_request_size=16384)\n\n# Configure CORS\nserver.set_cors_config(\n    allow_origins=['*'],\n    allow_methods=['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'],\n    allow_headers=['Content-Type', 'Authorization'],\n    allow_credentials=True,\n    max_age=3600\n)\n\n@server.route('/', methods=['GET'])\ndef home(query_params, headers, body):\n    name = query_params.get('name', 'Guest')\n    return Response(f\"\u003ch1\u003eWelcome to MicroPython HTTP Server, {name}!\u003c/h1\u003e\")\n\n@server.route('/api/data', methods=['GET', 'POST'])\ndef api_data(query_params, headers, body):\n    if headers.get('content-type') == 'application/json':\n        data = HTTPServer.parse_json(body)\n        response_data = {\n            \"message\": \"Data received\",\n            \"data\": data,\n            \"query_params\": query_params\n        }\n        return Response(response_data)\n    raise HTTPError(400, \"Invalid Content-Type\")\n\n@server.route('/static/style.css', methods=['GET'])\ndef serve_css(query_params, headers, body):\n    return HTTPServer.serve_file('static/style.css', 'text/css')\n\nif __name__ == '__main__':\n    server.start()\n```\n\n## API Reference\n\n### HTTPServer\n\nThe main server class.\n\n#### Constructor\n\n```python\nHTTPServer(port=80, log_level='INFO', max_request_size=8192, cors_config=None)\n```\n\n- `port`: The port to run the server on (default: 80)\n- `log_level`: Logging level (default: 'INFO')\n- `max_request_size`: Maximum allowed request size in bytes (default: 8192)\n- `cors_config`: CORS configuration (default: None)\n\n#### Methods\n\n- `start()`: Start the server\n- `route(path, methods=None)`: Decorator to register a route\n- `set_cors_config(...)`: Configure CORS settings\n- `serve_file(file_path, content_type)`: Serve a static file\n- `parse_json(body)`: Parse JSON data\n\n### Response\n\nClass for creating HTTP responses.\n\n#### Constructor\n\n```python\nResponse(body='', status_code=200, headers=None)\n```\n\n### HTTPError\n\nCustom exception for HTTP errors.\n\n#### Constructor\n\n```python\nHTTPError(status_code, message)\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is open source and available under the [MIT License](LICENSE).","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fishangavidusha%2Fhttpserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fishangavidusha%2Fhttpserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fishangavidusha%2Fhttpserver/lists"}