I’m trying to learn about creating web apps with Go and very much enjoying making progress here and there. So far I’ve been able to implement a couple of template based projects with static data but now I need to step things up a little.
I would like to set up a simple site which can accept some text in an input box and when a submit button is clicked I would like to be execute some processing on the text which was entered. Are there any good SIMPLE examples of doing this anywhere that are not overly complicated?
Would greatly appreciate any examples or tutorials on how to accomplish this.
All you have to do is create a web server with the net/http package that registers some routes to a mux, those routes are established by connecting them to a HandleFunc, which is a function that matches the interface defined in the http package. You will parse your data from the form post request on the rendered page.
After a couple of hours of messing around and head banging I’ve cobbled these together. I suppose its not impossible that they might be of some use to others at some time in the future as crazy simple examples of how to:
Run a simple web server
Collect some input into a textbox
Allow the user to click a submit box and have the textbox data sent back to a Go function.
Perform some processing on the data sent and send it back for display on the page
Works great and I’m delighted with it. This could be the bare bones of something much more sophisticated!