eegloo
eegloo

Reputation: 171

How to Create Form Template in Go Programming?

How to Create Login Form (username and Password) Template in Go Programming?

Upvotes: 0

Views: 655

Answers (1)

fmt.Println.MKO
fmt.Println.MKO

Reputation: 2060

using template on appengine is only posible if you pass the html from field, because of appengine rules you dont have access to the filesystem

here is an example

const loginTemplateHTML = `<html>
  <body>
    <form action="/login" method="post">
      <div><input name="username" type="text" /></div>
      <div><input name="password" type="password" /></div>
      <div><input type="submit" value="login"></div>
    </form>
  </body>
</html>
    `    
var loginTemplate = template.Must(template.New("Login").Parse(loginTemplateHTML))

func login (w http.ResponseWriter, r *http.Request) {
    if err := loginTemplate.Execute(w,nil); err != nil {
         http.Error(w, err.String(), http.StatusInternalServerError)
    }
}

Upvotes: 1

Related Questions