Created
October 14, 2018 11:18
-
-
Save cosminpopescu14/6ab3cb1b6a59ef218e2baeb5e4b97a56 to your computer and use it in GitHub Desktop.
Simple go http server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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