FAQ
Hi all golangs,

I am really excited about go-lang. Its fantastic how you can start a
webserver from within the language.

Here is my request:
i want to build a simple application with which will have a page called
HelloForm where a user will simply put in their name and a WebResponce Page
which takes the parameter of the name and displays e.g. "Hello Will". I
want to see two templates, one for HelloForm and another for WebResponce
Pages

in html the equivalent would be:
e.g. if it were HelloForm.html
<html>
<head><title>HelloForm</title></head>
<body>
<form action='WebResponce' method='post'>

<input type = 'text' name ='name'><br />

<input type='submit' value='Submit' id='submitForm' name='submitForm' >
</form>
</body>
</html>

How do i build this simple application with using two pages (bound to two
templates) and the webserver file? I have gone through many examples
online and this is not very clear.

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Christoph Hack at Aug 6, 2013 at 8:27 pm
    Hi will,

    I hope this example is enough to get you started:
    https://gist.github.com/tux21b/6168270

    Feel free to ask any additional questions you might have.

    Regards,
    Christoph

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Will at Aug 6, 2013 at 8:44 pm
    Hi Christoph,

    Thank you so much. This looks really nice. Its a good start

    Some observations
    ... I would like the answer to render in a different page and perhaps have
    several files instead of everything being in one file. (The reason
    obviously is supposing i want 1000 webpages, i would put that in one file
    as it would be too large to work through.

    regards,

    William
    On Tuesday, 6 August 2013 22:27:29 UTC+2, Christoph Hack wrote:

    Hi will,

    I hope this example is enough to get you started:
    https://gist.github.com/tux21b/6168270

    Feel free to ask any additional questions you might have.

    Regards,
    Christoph
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Christoph Hack at Aug 6, 2013 at 8:56 pm

    On Tuesday, August 6, 2013 10:44:07 PM UTC+2, will wrote:

    ... I would like the answer to render in a different page
    Change the line with
    <form method="POST">
    to something like:
    <form method="POST" action="/greeting">

    and register an additional HTTP handler for "/greeting":

    http.HandleFunc("/greeting", handleGreeting)

    The handleGreeting function should have the same signature as the
    handleIndex handler, but you can move most of the stuff from the
    handleIndex method there.

    and perhaps have several files instead of everything being in one file.
    (The reason obviously is supposing i want 1000 webpages, i would put that
    in one file as it would be too large to work through
    Use the template.ParseFiles or template.ParseGlob function instead of
    template.Parse. Both of these functions allow you to specify the filenames
    of your template files instead of the template content.

    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Will at Aug 6, 2013 at 9:06 pm
    Thankyou so much. Your responses have greatly assisted me.
    On Tuesday, 6 August 2013 22:56:55 UTC+2, Christoph Hack wrote:
    On Tuesday, August 6, 2013 10:44:07 PM UTC+2, will wrote:

    ... I would like the answer to render in a different page
    Change the line with
    <form method="POST">
    to something like:
    <form method="POST" action="/greeting">

    and register an additional HTTP handler for "/greeting":

    http.HandleFunc("/greeting", handleGreeting)

    The handleGreeting function should have the same signature as the
    handleIndex handler, but you can move most of the stuff from the
    handleIndex method there.

    and perhaps have several files instead of everything being in one file.
    (The reason obviously is supposing i want 1000 webpages, i would put that
    in one file as it would be too large to work through
    Use the template.ParseFiles or template.ParseGlob function instead of
    template.Parse. Both of these functions allow you to specify the filenames
    of your template files instead of the template content.
    --
    You received this message because you are subscribed to the Google Groups "golang-nuts" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedAug 6, '13 at 8:05p
activeAug 6, '13 at 9:06p
posts5
users2
websitegolang.org

2 users in discussion

Will: 3 posts Christoph Hack: 2 posts

People

Translate

site design / logo © 2022 Grokbase