Advertisement
Guest User

Untitled

a guest
Jun 13th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.45 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "io"
  5.     "net/http"
  6. )
  7.  
  8. func main() {
  9.     http.HandleFunc("/", foo)
  10.     http.Handle("/favicon.ico", http.NotFoundHandler())
  11.     http.ListenAndServe(":8080", nil)
  12. }
  13.  
  14. func foo(w http.ResponseWriter, req *http.Request) {
  15.     v := req.FormValue("q")
  16.     w.Header().Set("Content-Type", "text/html; charset=utf-8")
  17.     io.WriteString(w, `
  18.         <form method="post">
  19.             <input type="text" name="q">
  20.             <input type="submit">
  21.         </form>
  22.         <br>`+v)
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement