Skip to content

Instantly share code, notes, and snippets.

@jamescun
Created September 3, 2015 12:15
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 jamescun/620677003347ae85677b to your computer and use it in GitHub Desktop.
Save jamescun/620677003347ae85677b to your computer and use it in GitHub Desktop.
package main
import (
"net/http"
)
type Handler struct{}
func (h Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("hello world"))
}
func main() {
println("listening on 127.0.0.1:8080")
err := http.ListenAndServe("127.0.0.1:8080", Handler{})
if err != nil {
panic(err)
}
}
var http = require("http");
function handler(req, res) {
res.end("hello world")
}
var server = http.createServer(handler);
server.listen(8080, function() {
console.log("listening on 127.0.0.1:8080")
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment