diff --git a/tools/serve b/tools/serve index 7f67eb8..baf68d1 100755 --- a/tools/serve +++ b/tools/serve @@ -1,19 +1,3 @@ -#!/usr/bin/python +#!/bin/bash -import SimpleHTTPServer -import SocketServer -import os - -PORT = 8000 - -public_dir = os.path.join(os.path.dirname(__file__), '..', 'public') -os.chdir(public_dir) - -Handler = SimpleHTTPServer.SimpleHTTPRequestHandler -Handler.extensions_map.update({ - '': 'text/html', -}); -httpd = SocketServer.TCPServer(("", PORT), Handler) - -print("Serving Go by Example at http://127.0.0.1:{}".format(PORT)) -httpd.serve_forever() +exec go run tools/serve.go diff --git a/tools/serve.go b/tools/serve.go new file mode 100644 index 0000000..b31a6b0 --- /dev/null +++ b/tools/serve.go @@ -0,0 +1,13 @@ +package main + +import ( + "fmt" + "net/http" +) + +func main() { + port := "8000" + publicDir := "public" + fmt.Printf("Serving Go by Example at http://127.0.0.1:%s\n", port) + http.ListenAndServe(":"+port, http.FileServer(http.Dir(publicDir))) +}