Building a Web server in Bash, part III - Login Leandro Proença on August 01, 2022 In the previous posts we've seen how to manipulate sockets using netcat. Moreover, we learned how to start reading and parsing an HTTP message usin... Read full post Submit Preview Dismiss Collapse Expand David David David Follow I write about my professional and educational experiences as a self-taught software developer. Joined Jul 7, 2019 • Sep 14 '22 Dropdown menu Copy link Hide Thanks for the great article. One thing I didn't understand is: Where does home.html parse {{name}} from? Collapse Expand Leandro Proença Leandro Proença Leandro Proença Follow Programmer • I occasionally write blog posts in both English and Brazilian Portuguese. Location Brazil Education BSc, Information Systems Work Software Developer Joined Aug 8, 2017 • Sep 14 '22 Dropdown menu Copy link Hide Using sed: RESPONSE=$(cat home.html | \ sed "s/{{$COOKIE_NAME}}/$COOKIE_VALUE/") Enter fullscreen mode Exit fullscreen mode Did I answer your question? Collapse Expand David David David Follow I write about my professional and educational experiences as a self-taught software developer. Joined Jul 7, 2019 • Sep 21 '22 • Edited on Sep 21 • Edited Dropdown menu Copy link Hide Thanks for the reply. Not quite. shouldn't there be a name= somewhere? Collapse Expand Mac Mac Mac Follow Joined Feb 20, 2023 • Mar 30 '24 Dropdown menu Copy link Hide Informative post! I will let you know, you define the function as handleRequest however in one call of it you misname it: cat response | nc -lN 3000 | processRequest Collapse Expand stardust stardust stardust Follow work、exercise、study Location peking Joined May 8, 2021 • May 21 '25 Dropdown menu Copy link Hide keep the server run forever while true; do cat response | nc -lN 3000 | processRequest done Enter fullscreen mode Exit fullscreen mode processRequest -> handleRequest Collapse Expand Tomas Tomas Tomas Follow Joined Nov 30, 2024 • Nov 30 '24 Dropdown menu Copy link Hide Seems Part III is broken. Page shows "Liquid syntax error: Unknown tag 'endraw' " Collapse Expand Leandro Proença Leandro Proença Leandro Proença Follow Programmer • I occasionally write blog posts in both English and Brazilian Portuguese. Location Brazil Education BSc, Information Systems Work Software Developer Joined Aug 8, 2017 • Dec 2 '24 Dropdown menu Copy link Hide thanks, it might be a platform issue, I edited then just saved the post. seems working now Collapse Expand Michael Hotwagner Michael Hotwagner Michael Hotwagner Follow Full stack software engineer Joined May 13, 2024 • May 13 '24 Dropdown menu Copy link Hide Just want to give big thanks for this awesome post. Seriously great stuff! Collapse Expand Vinícius Gajo Vinícius Gajo Vinícius Gajo Follow Software and Mechatronics engineer. Other networks: - https://gaio.dev - https://github.com/64J0 - https://leetcode.com/64J0 - https://exercism.org/profiles/64J0 Location Brazil Education Mechatronics Engineer at CEFET-MG Work Software engineer Joined Apr 13, 2021 • Aug 17 '22 Dropdown menu Copy link Hide The cat trick does not work for me. When I try to understand what is happening in Chrome DevTools it shows me this: Apparently the server is not able to parse correctly the HTML file. Did you have this problem before? Collapse Expand Leandro Proença Leandro Proença Leandro Proença Follow Programmer • I occasionally write blog posts in both English and Brazilian Portuguese. Location Brazil Education BSc, Information Systems Work Software Developer Joined Aug 8, 2017 • Aug 18 '22 Dropdown menu Copy link Hide never seen this before. maybe OS issue? netcat implementation issue? anyway, try using \n instead of \r\n Collapse Expand Vinícius Gajo Vinícius Gajo Vinícius Gajo Follow Software and Mechatronics engineer. Other networks: - https://gaio.dev - https://github.com/64J0 - https://leetcode.com/64J0 - https://exercism.org/profiles/64J0 Location Brazil Education Mechatronics Engineer at CEFET-MG Work Software engineer Joined Apr 13, 2021 • Aug 18 '22 Dropdown menu Copy link Hide Maybe the problem is the OS or the IDE I'm using (Emacs). I tried setting explicitly the \r\n but it did not work either. But, it worked after I set the headers in the string, and just cat the HTML content, like this: RESPONSE="HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n$(cat html/home.html)" Enter fullscreen mode Exit fullscreen mode Leandro Proença Leandro Proença Leandro Proença Follow Programmer • I occasionally write blog posts in both English and Brazilian Portuguese. Location Brazil Education BSc, Information Systems Work Software Developer Joined Aug 8, 2017 • Aug 18 '22 Dropdown menu Copy link Hide good catch! yes, unfortunately when dealing with stuff low-level we may face OS/tools implementations issues Collapse Expand Aaron Gray Aaron Gray Aaron Gray Follow Open Source Software Engineer. Joined Oct 7, 2018 • Mar 18 '24 Dropdown menu Copy link Hide Hi, can you wrap it all up in a github repo please if you have not done so already ? Code of Conduct • Report abuse
Thanks for the great article. One thing I didn't understand is: Where does
home.htmlparse{{name}}from?Using
sed:Did I answer your question?
Thanks for the reply. Not quite. shouldn't there be a
name=somewhere?Informative post!
I will let you know, you define the function as
handleRequesthowever in one call of it you misname it:cat response | nc -lN 3000 | processRequestkeep the server run forever
processRequest -> handleRequest
Seems Part III is broken. Page shows "Liquid syntax error: Unknown tag 'endraw' "
thanks, it might be a platform issue, I edited then just saved the post. seems working now
Just want to give big thanks for this awesome post. Seriously great stuff!
The
cattrick does not work for me. When I try to understand what is happening in Chrome DevTools it shows me this:Apparently the server is not able to parse correctly the HTML file. Did you have this problem before?
never seen this before. maybe OS issue? netcat implementation issue?
anyway, try using \n instead of \r\n
Maybe the problem is the OS or the IDE I'm using (Emacs). I tried setting explicitly the \r\n but it did not work either. But, it worked after I set the headers in the string, and just cat the HTML content, like this:
good catch! yes, unfortunately when dealing with stuff low-level we may face OS/tools implementations issues
Hi, can you wrap it all up in a github repo please if you have not done so already ?