运行Google AppEngine HelloWorld应用程序

时间:2015-09-10 15:37:51

标签: macos google-app-engine

你能不能帮我看一下Google AppEngine,因为我看不到来自http://localhost:8080的任何回复,虽然我可以看到下面的运行... 另请注意,我也无法使用Ctrl + C关闭。我目前在Mac OSX 10.10.5上运行它。

hello.go

package hello

import (
    "fmt"
    "net/http"
)

func init() {
    http.HandleFunc("/", handler)
}

func handler(w http.ResponseWriter, r *http.Request) {
    fmt.Fprint(w, "Hello, world!")
}

的app.yaml

application: helloworld
version: 1
runtime: go
api_version: go1

handlers:
- url: /.*
  script: _go_app

终端输出

INFO     2015-09-10 15:25:33,421 devappserver2.py:763] Skipping SDK update check.
WARNING  2015-09-10 15:25:33,480 simple_search_stub.py:1126] Could not read search indexes from /var/folders/dw/j8wnb7bn3bb0x_lh0v_gb1nw0000gn/T/appengine.helloworld.someuser/search_indexes
INFO     2015-09-10 15:25:33,483 api_server.py:205] Starting API server at: http://localhost:50462
INFO     2015-09-10 15:25:33,487 dispatcher.py:197] Starting module "default" running at: http://localhost:8080
INFO     2015-09-10 15:25:33,489 admin_server.py:118] Starting admin server at: http://localhost:8000

1 个答案:

答案 0 :(得分:2)

我已尝试重现您的问题,但是,我不能 - 代码运行良好。

在另一个终端curl上运行以检查网址,我在其他终端上看到

$ curl http://localhost:8080
Hello, world!$ 

完全按照我的意愿,并且,在我运行goapp的终端窗口中,会显示以下日志行:

INFO     2015-09-12 18:00:35,470 module.py:737] default: "GET / HTTP/1.1" 200 13
INFO     2015-09-12 18:00:52,841 module.py:737] default: "GET / HTTP/1.1" 200 13
INFO     2015-09-12 18:00:53,324 module.py:737] default: "GET /favicon.ico HTTP/1.1" 200 13

再次,完全按照他们的意愿。此外,当我切换到运行goapp的终端并点击control-C时,我再次按预期看到了:

^Cgoapp: caught SIGINT, waiting for dev_appserver.py to shut down
INFO     2015-09-12 18:01:46,762 shutdown.py:45] Shutting down.
INFO     2015-09-12 18:01:46,763 api_server.py:588] Applying all pending transactions and saving the datastore
INFO     2015-09-12 18:01:46,763 api_server.py:591] Saving search indexes
$ 

我也在OSX 10.10.5(14F27)上。您在另一个终端窗口上使用curl命令观察到了什么,包括后者和您正在运行的终端goapp?当您将焦点切换回您正在运行goapp的终端并点击控制C时,您会观察到什么?