diff options
author | Andrew Gerrand <adg@golang.org> | 2013-03-08 09:22:40 +1100 |
---|---|---|
committer | Andrew Gerrand <adg@golang.org> | 2013-03-08 09:22:40 +1100 |
commit | 0ee9872fcd5cf9023cb43a68faf67203cbe81295 (patch) | |
tree | faa873e0163e1d1b35e86b812de77afd3da7f6bb /cmd/blog/local.go | |
parent | c26ca9cbba2bc725e1d7d26754ac5167a44ddb76 (diff) |
go.blog: blog server
R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/7382064
Diffstat (limited to 'cmd/blog/local.go')
-rw-r--r-- | cmd/blog/local.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/cmd/blog/local.go b/cmd/blog/local.go new file mode 100644 index 0000000..17ebae4 --- /dev/null +++ b/cmd/blog/local.go @@ -0,0 +1,34 @@ +// Copyright 2013 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !appengine + +// This file implements a stand-alone blog server. + +package main + +import ( + "flag" + "log" + "net/http" +) + +var ( + httpAddr = flag.String("http", "localhost:8080", "HTTP listen address") + contentPath = flag.String("content", "content/", "path to content files") + templatePath = flag.String("template", "template/", "path to template files") + staticPath = flag.String("static", "static/", "path to static files") +) + +func main() { + flag.Parse() + s, err := NewServer("/", *contentPath, *templatePath) + if err != nil { + log.Fatal(err) + } + http.Handle("/", s) + fs := http.FileServer(http.Dir(*staticPath)) + http.Handle("/static/", http.StripPrefix("/static/", fs)) + log.Fatal(http.ListenAndServe(*httpAddr, nil)) +} |