繁体   English   中英

Google App Engine Go SDK:请求“ /”失败

[英]Google App Engine Go SDK: Request to '/' failed

我刚开始使用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 -

我在Google上进行了搜索,并尝试在此处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上,运行版本go1.2.1 linux / 386
  • 使用go_appengine_sdk_linux_386-1.9.4.zip

这是我的hello.go和app.yaml

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,")
}

的app.yaml

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

handlers:
- url: /.*
  script: _go_app

谢谢,

不知道这是否会帮助任何人,但我遇到了完全相同的问题,并最终将其跟踪到我的主机文件中。 基本上发生的事情是App Engine服务器在0.0.0.0:8080上运行,但界面/输出显示localhost:8080。 在我的主机文件中0.0.0.0:8080没有映射到localhost,所以:

  1. 使用vim或任何其他方式编辑/private/etc/hosts文件
  2. 0.0.0.0 localhost添加到您的主机文件
  3. 保存,启动新的终端,然后尝试再次运行您的appengine服务器

经过简单的编辑后,一切对我都有效。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM