[{"data":1,"prerenderedAt":467},["ShallowReactive",2],{"project-29794979":3},{"id":4,"name":5,"line":6,"line_source":7,"title":8,"url":9,"domain":10,"maker":11,"posted_at":12,"year":13,"points":14,"comments":15,"rank_in_year":16,"shown_in_year":17,"top":18,"tier":19,"category":20,"subcategory":21,"format":22,"keywords":23,"reception":27,"sentiment":28,"stance_mix":29,"scored_comments":34,"aspects":35,"strip":43,"post_text":44,"what":45,"said":76,"maker_in_thread":162,"shape":173,"grid":178,"attempts":429,"same_week":430,"maker_shows":237,"maker_hidden":459,"reader_version":460,"card":461},"29794979","bash web server","A pure bash web server. No netcat, socat, etc.","title","Show HN: A pure bash web server. No netcat, socat, etc.","https:\u002F\u002Fgithub.com\u002Fdzove855\u002FBash-web-server","github.com","dzove855",1641306013,2022,224,97,237,2570,10,"notable","dev_tools","web server","cli",[24,21,25,26],"bash","shell script","netcat alternative","curious",-0.026,{"positive":30,"neutral":31,"mixed":32,"critical":33},5,13,1,7,26,{"execution":36,"design":38,"idea":40,"docs":41,"performance":42},{"positive":32,"critical":37},3,{"positive":39,"critical":32},0,{"positive":37,"critical":39},{"positive":32,"critical":39},{"positive":39,"critical":32},[30,37,37,32,37,37,37,37,39,39,39,39,39,39,39,39,39,39,39,37,39,39,39,39,32,30,37,39,30,39,32,32,39,39,37,30,39,32,32,32],null,{"problem":46,"audience":44,"pricing":44,"motivation":56,"time_to_build":44,"stack":64,"openness":74,"stage":75,"team_size":74},{"value":47,"source":48,"evidence":49},"Runs a web server using only bash, with no external network tools like netcat or socat.","maker",[50,52],{"id":51},"post",{"id":53,"by":54,"text":55},"29795379","BeefWellington","I appreciate the ingenuity here given the other recent posts, but this still requires executing an external application to perform the accept() part. Definitely closest to the…",{"value":57,"source":58,"evidence":59},"Puzzle of implementing a web server in a highly restrictive environment with only bash builtins.","commenter",[60],{"id":61,"by":62,"text":63},"29795823","umvi","Ha, this is more like a puzzle than anything - trying to implement a protocol in a highly restrictive environment. For anyone looking for an easy way to spin up a command line…",[65],{"value":66,"source":48,"evidence":67},"Bash",[68,71],{"id":69,"by":11,"text":70},"29795393","Basically yes, but it's a loadable builtin.",{"id":72,"by":11,"text":73},"29796228","Bash is not mean for kind of projects like this. I even develop on other languages. But i like bash. A good bash script, is like reading a novel, because it's challenging to have…","unknown","beta",{"praise":77,"objections":93,"requests":117,"questions":125,"alternatives":136},[78],{"value":79,"source":58,"evidence":80},"Clever use of bash builtins and techniques",[81,85,89],{"id":82,"by":83,"text":84},"29796002","pdkl95","Regarding the creation and removal of a tempfile (line 72 & 85): ``` local tmpFile=\"$ {TMPDIR:-\u002Ftmp\u002Fbash-web-server.$$}\" # ... rm \"$tmpFile\" ``` To avoid collisions when the PID…",{"id":86,"by":87,"text":88},"29795361","spicybright","Definitely scary, but I love things like this. Takes a lot of creativity! There was a post a bit ago that had a one liner for a basic web server using net cat: ``` while : ; do…",{"id":90,"by":91,"text":92},"29796916","mro_name","I like those unorthodox, against-cargo-cult approaches. Thx!",[94,108],{"value":95,"source":58,"evidence":96},"Bash is a poor language for projects like this and hard to maintain",[97,101,105],{"id":98,"by":99,"text":100},"29795784","encryptluks2","I used to see value in scripts like this, but often these Bash scripts do quite the opposite. It may be readable for those that only know Bash, but you'll probably be happier if…",{"id":102,"by":103,"text":104},"29796187","pmarreck","The other day I wrote this bash code after getting frustrated with the password generators available to me, just so I had something to use right in the shell:…",{"id":106,"by":103,"text":107},"29796403","I get it. The challenging part is fun. You can learn all the corner cases, the clever bash-isms, and then show off. But the code you end up with is essentially unmaintainable,…",{"value":109,"source":58,"evidence":110},"Single-process design is slow and scales poorly",[111,114],{"id":112,"by":11,"text":113},"29807379","I follow some projects from you on github. Keep up the work! Falling back to something like socat, would destroy the whole idea behind it. I think the best way is patching accept…",{"id":115,"by":11,"text":116},"29797571","Well benchmarking it os currently not possible. I will try it in a few days and provide some benchmarks.",[118],{"value":119,"source":58,"evidence":120},"Benchmarks of performance",[121],{"id":122,"by":123,"text":124},"29797552","nottorp","I wonder if it's faster than the same thing in javascript...",[126],{"value":127,"source":58,"evidence":128},"How the accept builtin and fd handling work",[129,133],{"id":130,"by":131,"text":132},"29796431","sillysaurusx","This script taught me a few things! Since it's kind of impossible to google, what does this construct mean? ``` while :; do ``` It's clearly a while true loop, but why does an…",{"id":134,"by":11,"text":135},"29796450","Well that's true. I took me two hours to get this done. Since accept was not clear at the beginning. But it will be cleaner in the future, i'm still not convinced how it works…",[137,141,148,155],{"value":138,"source":58,"evidence":139},"python3 -m http.server",[140],{"id":61,"by":62,"text":63},{"value":142,"source":58,"evidence":143},"darkhttpd",[144],{"id":145,"by":146,"text":147},"29796290","pcranaway","I use darkhttpd from time to time, it supports streaming: https:\u002F\u002Fgithub.com\u002Femikulic\u002Fdarkhttpd",{"value":149,"source":58,"evidence":150},"busybox httpd",[151],{"id":152,"by":153,"text":154},"29797793","0xbadcafebee","If you have access to a busybox executable, it comes with a quite capable little httpd with \u002Fcgi-bin\u002F for CGI apps. If you have a wifi router, the web interface might be running…",{"value":156,"source":58,"evidence":157},"sthttpd",[158],{"id":159,"by":160,"text":161},"29804440","makeworld","Another option: https:\u002F\u002Fgithub.com\u002Fblueness\u002Fsthttpd",{"comments":31,"answered":39,"key":163},[164,167,170],{"id":165,"text":166},"29796092","I always use mktemp and trap to remove tmp files. But in this script i would like to avoid external commands. I will even remove the use of tmp files kn thw future.",{"id":168,"text":169},"29806418","For creating some kind IPC, i would create a named fifo or even use coproc (see man bash)",{"id":171,"text":172},"29843793","Since now, multiple concurrent connections will work after my patch. (Need to add subshell) i will need to consider using fd as output cache. Instead of temporary files.",{"commenters":174,"max_depth":175,"maker_replies":31,"first_comment_mins":176,"lifespan_hours":177},60,8,33,187,[179,181,183,187,191,194,197,198,202,204,206,208,209,211,213,215,218,222,225,227,230,232,234,236,238,239,242,245,247,250,253,255,257,260,262,265,268,271,274,276,278,279,280,283,286,288,291,294,295,296,299,302,305,308,310,313,315,318,321,324,327,330,332,334,336,339,342,345,347,350,353,354,357,359,360,361,365,368,371,374,376,379,383,386,390,393,395,399,402,405,408,413,415,416,419,421,425],[82,39,30,180,83,39],"project\u002Fpositive\u002Fexecution",[165,39,39,182,11,32],"maker\u002Fneutral\u002Fexecution",[184,39,37,185,186,39],"29796740","project\u002Fneutral\u002Fexecution","goombacloud",[188,39,39,189,190,39],"29798178","commenter\u002Fneutral\u002Fnone","ghthor",[192,39,39,189,193,39],"29800257","stouset",[195,39,37,185,196,39],"29801475","Klasiaster",[168,39,39,185,11,32],[199,39,32,200,201,39],"29830019","project\u002Fcritical\u002Fexecution","labawi",[203,39,37,185,186,39],"29841530",[205,39,37,185,186,39],"29841714",[207,39,37,185,196,39],"29843702",[171,39,39,182,11,32],[210,39,37,185,196,39],"29844820",[212,39,37,185,196,39],"29845256",[214,39,39,182,11,32],"29844979",[216,39,37,185,217,39],"29802569","mmmooo",[219,32,39,220,221,39],"29795668","other\u002Fneutral\u002Fnone","maxbond",[223,32,37,185,224,39],"29796251","dundarious",[226,32,39,189,221,39],"29800937",[228,32,39,189,229,39],"29800386","thyrox",[231,32,39,189,224,39],"29801213",[233,32,39,189,221,39],"29801231",[235,32,39,189,229,39],"29904155",[61,237,39,220,62,39],2,[145,237,39,220,146,39],[240,237,39,220,241,39],"29796587","masklinn",[243,237,39,220,244,39],"29797440","javajosh",[246,237,39,220,241,39],"29798355",[248,237,39,220,249,39],"29798676","londons_explore",[251,237,39,220,252,39],"29801439","jcims",[254,237,39,220,244,39],"29803219",[256,237,39,220,252,39],"29803257",[258,237,39,189,259,39],"29799656","teh_klev",[261,237,39,189,241,39],"29799863",[263,237,39,220,264,39],"29797263","asiachick",[266,237,39,220,267,39],"29797539","vimsee",[269,237,39,220,270,39],"29797914","moreati",[272,237,39,220,273,39],"29799721","TingPing",[275,237,39,220,264,39],"29814238",[277,237,39,220,259,39],"29799788",[152,237,39,220,153,39],[159,237,39,220,160,39],[281,37,39,220,282,39],"29795376","tyingq",[284,37,39,220,285,39],"29796139","drvdevd",[287,37,39,220,282,39],"29796245",[289,37,39,220,290,39],"29805089","genewitch",[53,292,37,293,54,39],4,"project\u002Fmixed\u002Fexecution",[69,292,39,182,11,32],[130,30,39,220,131,39],[297,30,39,220,298,39],"29796456","framecowbird",[300,30,39,220,301,39],"29796458","StanAngeloff",[303,30,39,220,304,39],"29796459","veltas",[306,30,39,220,307,39],"29796794","vultour",[309,30,39,220,282,39],"29796901",[311,30,39,220,312,39],"29797176","bewuethr",[314,30,39,220,304,39],"29798901",[316,30,39,220,317,39],"29798452","mturmon",[319,30,39,220,320,39],"29798884","Trufa",[322,30,39,220,323,39],"29803760","prettyStandard",[98,325,32,326,99,39],6,"project\u002Fcritical\u002Fdesign",[328,325,39,189,329,39],"29797547","drran",[331,325,39,189,99,39],"29802509",[86,33,30,333,87,39],"project\u002Fpositive\u002Fidea",[335,33,39,182,11,32],"29795383",[337,33,37,185,338,39],"29795673","hericium",[340,33,39,189,341,39],"29797696","skrtskrt",[343,33,39,189,344,39],"29798255","arbitrage",[346,33,39,189,341,39],"29813060",[348,33,39,189,349,39],"29798309","aidenn0",[351,175,30,333,352,39],"29803107","hyperupcall",[112,175,39,185,11,32],[102,355,39,356,103,39],9,"other\u002Fcritical\u002Fnone",[72,355,39,358,11,32],"maker\u002Fneutral\u002Fnone",[106,355,32,200,103,39],[134,355,39,182,11,32],[362,355,32,363,364,39],"29796892","maker\u002Fcritical\u002Fexecution","carlhjerpe",[366,355,39,220,367,39],"29796443","ramses0",[369,355,39,220,370,39],"29797030","istjohn",[372,355,39,220,373,39],"29798358","wgjordan",[375,355,39,189,103,39],"29799430",[377,355,39,220,378,39],"29799011","foxhop",[380,18,39,381,382,39],"29799391","other\u002Fneutral\u002Fdocs","ape4",[384,18,39,385,11,32],"29799417","commenter\u002Fneutral\u002Fdocs",[387,18,37,388,389,39],"29801033","project\u002Fneutral\u002Fdocs","garaetjjte",[391,18,30,392,382,39],"29809525","project\u002Fpositive\u002Fdocs",[90,394,30,333,91,39],11,[396,397,37,185,398,39],"29799673",12,"pxeger1",[400,397,39,401,11,32],"29800112","project\u002Fneutral\u002Fperformance",[403,31,39,220,404,39],"29797466","dheera",[406,407,39,185,11,32],"29837492",14,[409,410,32,411,412,39],"29801147",15,"project\u002Fcritical\u002Fnone","benbristow",[122,414,37,401,123,39],16,[115,414,39,401,11,32],[417,414,32,418,282,39],"29797828","project\u002Fcritical\u002Fperformance",[420,414,39,220,123,39],"29807845",[422,423,32,411,424,39],"29801586",17,"codeivore",[426,427,39,220,428,39],"29803815",18,"yeetaccount4",[],[431,436,441,446,450,455],{"id":432,"name":433,"points":434,"category":435},"29795482","OnlyRecipe.app",560,"consumer_social",{"id":437,"name":438,"points":439,"category":440},"29786132","Coqui",513,"ai",{"id":442,"name":443,"points":444,"category":445},"29803817","Black Magic",333,"productivity",{"id":447,"name":448,"points":449,"category":435},"29794079","travelfriends.xyz",235,{"id":451,"name":452,"points":453,"category":454},"29764785","USDZ.app",191,"creative",{"id":456,"name":457,"points":458,"category":20},"29779618","Changedetection.io",147,false,"v2",{"id":462,"name":5,"line":6,"ai":459,"cat":20,"year":13,"points":14,"comments":15,"rec":27,"s":463,"top":18,"kw":464,"maker":11,"domain":10,"tier":19,"attempts":39,"strip":465,"url":9,"mix":466,"praise":79,"objection":95,"sub":21},29794979,-0.03,[24,21,25,26],"5331333300000000000300001530501100350111",[30,31,32,33],1794036614850]