{"id":81,"date":"2010-11-23T23:20:31","date_gmt":"2010-11-23T23:20:31","guid":{"rendered":"https:\/\/www.cores2.com\/blog\/?p=81"},"modified":"2010-11-24T00:44:02","modified_gmt":"2010-11-24T00:44:02","slug":"mini-web-server","status":"publish","type":"post","link":"https:\/\/www.cores2.com\/blog\/?p=81","title":{"rendered":"Mini Web Server"},"content":{"rendered":"<p>Ever wanted to write a mini web server? Maybe you need an offline web GUI, or just wanted to see how a server works at the bare basics? Today I wrote a 400-line web server application that does the bare basics of fulfilling HTTP 1.1 requests. I also included MIME-type functionality, so when you browse a webpage, you correctly download content (i.e. treat an image as an image, not as a text file).<\/p>\n<p>Unlike Apache Server, I don&#8217;t include forking \/ threading for each session nor do I allow the ability to browser only a set directory. Simply put: this code is a proof of concept and only implements a minimal feature set &#8211; don&#8217;t use it in production code! If you do use it and expand on the base, tell me what you think and what you&#8217;ve added &#8211; I&#8217;ll be happy to hear of what happens to this code.<\/p>\n<p style=\"text-align: center;\"><object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"480\" height=\"385\" codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=6,0,40,0\"><param name=\"allowFullScreen\" value=\"true\" \/><param name=\"allowscriptaccess\" value=\"always\" \/><param name=\"src\" value=\"http:\/\/www.youtube.com\/v\/tHksZNw2tBs?fs=1&amp;hl=en_US\" \/><param name=\"allowfullscreen\" value=\"true\" \/><embed type=\"application\/x-shockwave-flash\" width=\"480\" height=\"385\" src=\"http:\/\/www.youtube.com\/v\/tHksZNw2tBs?fs=1&amp;hl=en_US\" allowscriptaccess=\"always\" allowfullscreen=\"true\"><\/embed><\/object><\/p>\n<p><a href=\"https:\/\/www.cores2.com\/blog\/files\/webserver\/\">Source code is hosted locally here<\/a> &#8211; this should only work for OSX and UNIX-like systems. Play around with the header file includes; some are specific to OSX.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ever wanted to write a mini web server? Maybe you need an offline web GUI, or just wanted to see how a server works at the bare basics? Today I wrote a 400-line web server application that does the bare &hellip; <a href=\"https:\/\/www.cores2.com\/blog\/?p=81\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-81","post","type-post","status-publish","format-standard","hentry","category-programming"],"_links":{"self":[{"href":"https:\/\/www.cores2.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/81","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.cores2.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.cores2.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.cores2.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.cores2.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=81"}],"version-history":[{"count":0,"href":"https:\/\/www.cores2.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/81\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.cores2.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=81"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.cores2.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=81"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.cores2.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=81"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}