【发布时间】:2014-05-19 08:55:47
【问题描述】:
我刚刚开始使用 GAE,我在这里有以下指南 https://developers.google.com/appengine/docs/go/gettingstarted/devenvironment 和一些你好词教程在这里 https://developers.google.com/appengine/docs/go/gettingstarted/helloworld。
我的问题是当我输入goapp serve 时它可以工作。并像这样显示日志:
INFO 2014-05-18 08:44:57,130 devappserver2.py:765] Skipping SDK update check.
WARNING 2014-05-18 08:44:57,135 api_server.py:374] Could not initialize images API; you are likely missing the Python "PIL" module.
INFO 2014-05-18 08:44:57,140 api_server.py:171] Starting API server at: http://localhost:59559
INFO 2014-05-18 08:44:57,154 dispatcher.py:182] Starting module "default" running at: http://localhost:8080
INFO 2014-05-18 08:44:57,156 admin_server.py:117] Starting admin server at: http://localhost:8000
但是,当我尝试访问 http://localhost:8080 时,它不会显示“你好,世界!”在浏览器中。和错误日志这样显示:
ERROR 2014-05-18 08:48:05,002 module.py:714] Request to '/' failed
Traceback (most recent call last):
File "/home/bayu/.go_appengine/google/appengine/tools/devappserver2/module.py", line 708, in _handle_request
environ, wrapped_start_response)
File "/home/bayu/.go_appengine/google/appengine/tools/devappserver2/request_rewriter.py", line 311, in _rewriter_middleware
response_body = iter(application(environ, wrapped_start_response))
File "/home/bayu/.go_appengine/google/appengine/tools/devappserver2/module.py", line 1228, in _handle_script_request
request_type)
File "/home/bayu/.go_appengine/google/appengine/tools/devappserver2/instance.py", line 382, in handle
request_type))
File "/home/bayu/.go_appengine/google/appengine/tools/devappserver2/http_proxy.py", line 148, in handle
connection.connect()
File "/home/bayu/.pyenv/versions/2.7.6/lib/python2.7/httplib.py", line 772, in connect
self.timeout, self.source_address)
File "/home/bayu/.pyenv/versions/2.7.6/lib/python2.7/socket.py", line 571, in create_connection
raise err
error: [Errno 111] Connection refused
INFO 2014-05-18 08:48:05,007 module.py:639] default: "GET / HTTP/1.1" 500 -
我用谷歌搜索它并在这里尝试另一个入门教程http://blog.joshsoftware.com/2014/03/12/learn-to-build-and-deploy-simple-go-web-apps-part-one/ 但它也不起作用。
我该怎么办?
- 我使用的是 ubuntu 12.04,Python 2.7.3,go 版本 go1.2.1 linux/386
- 使用 go_appengine_sdk_linux_386-1.9.4.zip
这是我的 hello.go 和 app.yaml
你好.go
package hello
import (
"fmt"
"net/http"
)
func init() {
http.HandleFunc("/", handler)
}
func handler(w http.ResponseWriter, r *http.Request) {
fmt.Fprint(w, "Hello,")
}
app.yaml
application: helloworld
version: 1
runtime: go
api_version: go1
handlers:
- url: /.*
script: _go_app
谢谢你,
【问题讨论】:
-
我已经在 SDK 1.2 版上运行了您的代码,并且运行没有问题,所以我认为问题出在 Python 设置/环境上,但它不是我的领域,所以想不出任何问题尝试。但是你的 .go 和 app.yaml 没问题。
标签: google-app-engine go