Skip to content
This repository has been archived by the owner on Nov 22, 2018. It is now read-only.

Commit

Permalink
go-tour: fix static content serving
Browse files Browse the repository at this point in the history
LGTM=hyangah
R=golang-codereviews, hyangah
CC=golang-codereviews
https://codereview.appspot.com/82430043
  • Loading branch information
adg committed Mar 31, 2014
1 parent b8dda42 commit d189525
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
5 changes: 4 additions & 1 deletion app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ api_version: go1
default_expiration: "7d"

handlers:

# Keep these static file handlers in sync with gotour/local.go.
- url: /favicon.ico
static_files: static/img/favicon.ico
upload: static/img/favicon.ico
- url: /content/img
static_dir: content/img
- url: /static/
- url: /static
static_dir: static
application_readable: true

- url: /(.*|list|lesson/.*|compile|fmt|script\.js)
script: _go_app

Expand Down
8 changes: 7 additions & 1 deletion gotour/local.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,16 @@ func main() {
}

http.HandleFunc("/", rootHandler)
http.Handle("/static/", http.FileServer(http.Dir(root)))
http.HandleFunc("/lesson/", lessonHandler)
http.Handle(socketPath, socket.Handler)

// Keep these static file handlers in sync with ../app.yaml.
static := http.FileServer(http.Dir(root))
http.Handle("/content/img/", static)
http.Handle("/static/", static)
imgDir := filepath.Join(root, "static", "img")
http.Handle("/favicon.ico", http.FileServer(http.Dir(imgDir)))

go func() {
url := "http://" + httpAddr
if waitServer(url) && *openBrowser && startBrowser(url) {
Expand Down
2 changes: 1 addition & 1 deletion static/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ ul {
left: 0;
width: 50%;
overflow: hidden;
background-image: url(/img/gopher.png);
background-image: url(/static/img/gopher.png);
background-repeat: no-repeat;
background-position: bottom;
background-color: #fafafa;
Expand Down

0 comments on commit d189525

Please sign in to comment.