{"id":20333324,"url":"https://github.com/daneelsan/toy-httpserver","last_synced_at":"2025-10-24T04:04:15.886Z","repository":{"id":250073849,"uuid":"831742383","full_name":"daneelsan/toy-httpserver","owner":"daneelsan","description":"Implementation of a toy HTTP server in lua, python, wolfram language and zig.","archived":false,"fork":false,"pushed_at":"2024-08-22T19:34:45.000Z","size":230,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-04T12:46:30.284Z","etag":null,"topics":["http-server","lua","mathematica","python","wolfram-language","zig"],"latest_commit_sha":null,"homepage":"","language":"Zig","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/daneelsan.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-07-21T13:53:14.000Z","updated_at":"2024-08-22T19:34:47.000Z","dependencies_parsed_at":"2024-11-14T20:43:29.701Z","dependency_job_id":null,"html_url":"https://github.com/daneelsan/toy-httpserver","commit_stats":null,"previous_names":["daneelsan/toy-httpserver"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/daneelsan/toy-httpserver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daneelsan%2Ftoy-httpserver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daneelsan%2Ftoy-httpserver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daneelsan%2Ftoy-httpserver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daneelsan%2Ftoy-httpserver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/daneelsan","download_url":"https://codeload.github.com/daneelsan/toy-httpserver/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/daneelsan%2Ftoy-httpserver/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280734533,"owners_count":26381849,"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","status":"online","status_checked_at":"2025-10-24T02:00:06.418Z","response_time":73,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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-server","lua","mathematica","python","wolfram-language","zig"],"created_at":"2024-11-14T20:30:44.988Z","updated_at":"2025-10-24T04:04:15.881Z","avatar_url":"https://github.com/daneelsan.png","language":"Zig","readme":"# Toy HTTP Server in multiple languages\n\nImplementation of a toy HTTP server in lua, python, wolfram language and zig.\nThe server is built on top of simple socket functionality, using TCP for the connection protocol and using localhost as the socket address.\nThe server currently only handles the GET method, but it could be easily be expanded.\n\n## Usage\n\nStart the HTTP server in various languages:\n\n### lua\n\nTested on:\n```shell\n$ lua -v\nLua 5.4.6  Copyright (C) 1994-2023 Lua.org, PUC-Rio\n```\n\nInstall the [luasocket](https://github.com/lunarmodules/luasocket) package (I chose `luarocks` for this):\n```shell\n$ luarocks install luasocket\n```\n\nAlso install the [mimetypes](https://github.com/lunarmodules/lua-mimetypes) package:\n```shell\n$ luarocks install mimetypes\n```\n\nStart the server:\n```shell\n$ lua httpserver.lua\n```\n\nNOTE: Testing against Google Chrome works fine. There seems to be an issue with Safari which needs more study.\n\n### python\n\nTested on:\n```shell\n$ python3 --version\nPython 3.9.6\n```\n\nStart the server:\n```shell\n$ python3 httpserver.py\n```\n\n### wolfram\n\nTested on:\n```shell\n$ wolframscript --version\nWolframScript 1.8.0 for Mac OS X ARM (64-bit)\n```\n\nStart the server:\n```shell\nwolframscript -f httpserver.wl\n```\n\n### zig\n\nTested on:\n```shell\n$ zig version\n0.14.0\n```\n\nStart the server:\n```shell\nzig run httpserver.zig\n```\n\n## Test\n\nSend a HTTP request to the toy HTTP server using curl:\n```shell\n$ curl -i 127.0.0.1:8888/index.html\nHTTP/1.1 200 OK\ncontent-type: text/html;charset=UTF-8\n\n\u003chtml\u003e\n    \u003chead\u003e\n        \u003ctitle\u003eIndex page\u003c/title\u003e\n    \u003c/head\u003e\n    \u003cbody\u003e\n        \u003ch1\u003eIndex page\u003c/h1\u003e\n        \u003cp\u003eThis is the index page.\u003c/p\u003e\n        \u003cimg src=\"./images/random.jpeg\"\u003e\n    \u003c/body\u003e\n\u003c/html\u003e\n```\n\nOr do it via a web browser:\n\u003cimage src=\"./images/browser_example.png\" alt=\"Request from a browser\"\u003e\n\nA request for a non-existant file returns the following:\n```shell\n$ curl -i --http0.9 127.0.0.1:8888/notafile.txt\nHTTP/1.1 404 Not Found\nServer: ToyServer (python)\nContent-Type: text/html\n\n\u003ch1\u003e404 Not Found\u003c/h1\u003e\n```\n\n## References\n\n### lua\n\n- [LuaSocket: Introduction to the core](https://lunarmodules.github.io/luasocket/introduction.html)\n- [Programming in Lua](https://www.lua.org/pil/contents.html)\n- [Lua Style Guide](https://github.com/Olivine-Labs/lua-style-guide)\n\n### python\n\n- [Writing an HTTP server from scratch](https://bhch.github.io/posts/2017/11/writing-an-http-server-from-scratch/)\n- [socket — Low-level networking interface](https://docs.python.org/3/library/socket.html)\n\n### wolfram\n\n- [SocketListen - Wolfram Language Documentation](http://reference.wolfram.com/language/ref/SocketListen.html)\n- [SocketOpen - Wolfram Language Documentation](http://reference.wolfram.com/language/ref/SocketOpen.html)\n- [SessionSubmit - Wolfram Language Documentation](http://reference.wolfram.com/language/ref/SessionSubmit.html)\n\n### zig\n\n- [Writing a HTTP Server in Zig](https://www.pedaldrivenprogramming.com/2024/03/writing-a-http-server-in-zig/)\n- [Socket programming in Zig (YouTube)](https://www.youtube.com/watch?v=V7Jql_SZ7kY)\n- [Zig Bits 0x4: Building an HTTP client/server from scratch](https://blog.orhun.dev/zig-bits-04/)\n- [Creating UDP server from scratch in Zig](https://blog.reilly.dev/creating-udp-server-from-scratch-in-zig)\n\n### other\n\n- [An overview of HTTP](https://developer.mozilla.org/en-US/docs/Web/HTTP/Overview)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaneelsan%2Ftoy-httpserver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdaneelsan%2Ftoy-httpserver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdaneelsan%2Ftoy-httpserver/lists"}