Skip to content

Instantly share code, notes, and snippets.

@cosminpopescu14
Created October 14, 2018 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cosminpopescu14/6ab3cb1b6a59ef218e2baeb5e4b97a56 to your computer and use it in GitHub Desktop.
Save cosminpopescu14/6ab3cb1b6a59ef218e2baeb5e4b97a56 to your computer and use it in GitHub Desktop.
Simple go http server
package main
import (
"io"
"net/http"
)
const port = ":8000"
func main() {
http.HandleFunc("/", foo)
http.ListenAndServe(port, nil)
}
func foo(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
io.WriteString(w, `
<form>
<input type="text" name="q">
<input type="submit">
</form>
<script src="https://gist.github.com/cosminpopescu14/1c25e7a270840b31426ab70c0ba286e5.js"></script>
`)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment