使用Google App Engine SDK在Go中创建简单应用程序

huangapple go评论90阅读模式
英文:

Simple Application in Go using Google App Engine SDK

问题

当我按照Google开发者的教程使用Go语言和Go应用引擎SDK创建一个简单应用程序时,在运行以下命令时:

goapp serve

我收到以下错误信息:

Traceback (most recent call last):
File "/home/kamal/go_appengine/dev_appserver.py", line 82, in <module>
_run_file(__file__, globals())
File "/home/kamal/go_appengine/dev_appserver.py", line 78, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/devappserver2.py",   line 1001, in <module>
main()
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 994, in main
dev_server.start(options)
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/devappserver2.py", line 754, in start
options.config_paths)
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 632, in __init__
module_configuration = ModuleConfiguration(config_path)
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 97, in __init__
self._config_path)
File "/home/kamal/go_appengine/google/appengine/tools/devappserver2/application_configuration.py", line 316, in _parse_configuration
config, files = appinfo_includes.ParseAndReturnIncludePaths(f)
File "/home/kamal/go_appengine/google/appengine/api/appinfo_includes.py", line 81, in ParseAndReturnIncludePaths
appyaml = appinfo.LoadSingleAppInfo(appinfo_file)
File "/home/kamal/go_appengine/google/appengine/api/appinfo.py", line 1873, in LoadSingleAppInfo
listener.Parse(app_info)
File "/home/kamal/go_appengine/google/appengine/api/yaml_listener.py", line 226, in Parse
self._HandleEvents(self._GenerateEventParameters(stream, loader_class))
File "/home/kamal/go_appengine/google/appengine/api/yaml_listener.py", line 177, in _HandleEvents
raise yaml_errors.EventError(e, event_object)
google.appengine.api.yaml_errors.EventError: Unknown url handler type.
URLMap 
auth_fail_action=redirect 
static_dir=None 
secure=default 
http_headers=None 
url=/.* 
static_files=None 
expiration=None 
upload=None 
api_endpoint=None 
script=None 
application_readable=None 
position=None 
login=optional 
mime_type=None 
require_matching_file=None
in "myapp/app.yaml", line 8, column 1
error while running dev_appserver.py: exit status 1

我不知道如何调试它。只需要一个提示就足够了。
另外,可能是因为我没有安装Web服务器吗?我需要安装Apache或Nginx来运行goapp serve吗?还是Go语言自己处理服务器相关的事情?

英文:

When I follow Google-Developers' tutorial for creating a simple application in Go using App Engine SDK for Go, while running the command

goapp serve

I receive the following error:

Traceback (most recent call last):
File &quot;/home/kamal/go_appengine/dev_appserver.py&quot;, line 82, in &lt;module&gt;
_run_file(__file__, globals())
File &quot;/home/kamal/go_appengine/dev_appserver.py&quot;, line 78, in _run_file
execfile(_PATHS.script_file(script_name), globals_)
File &quot;/home/kamal/go_appengine/google/appengine/tools/devappserver2/devappserver2.py&quot;,   line 1001, in &lt;module&gt;
main()
File &quot;/home/kamal/go_appengine/google/appengine/tools/devappserver2/devappserver2.py&quot;, line 994, in main
dev_server.start(options)
File &quot;/home/kamal/go_appengine/google/appengine/tools/devappserver2/devappserver2.py&quot;, line 754, in start
options.config_paths)
File &quot;/home/kamal/go_appengine/google/appengine/tools/devappserver2/application_configuration.py&quot;, line 632, in __init__
module_configuration = ModuleConfiguration(config_path)
File &quot;/home/kamal/go_appengine/google/appengine/tools/devappserver2/application_configuration.py&quot;, line 97, in __init__
self._config_path)
File &quot;/home/kamal/go_appengine/google/appengine/tools/devappserver2/application_configuration.py&quot;, line 316, in _parse_configuration
config, files = appinfo_includes.ParseAndReturnIncludePaths(f)
File &quot;/home/kamal/go_appengine/google/appengine/api/appinfo_includes.py&quot;, line 81, in ParseAndReturnIncludePaths
appyaml = appinfo.LoadSingleAppInfo(appinfo_file)
File &quot;/home/kamal/go_appengine/google/appengine/api/appinfo.py&quot;, line 1873, in LoadSingleAppInfo
listener.Parse(app_info)
File &quot;/home/kamal/go_appengine/google/appengine/api/yaml_listener.py&quot;, line 226, in Parse
self._HandleEvents(self._GenerateEventParameters(stream, loader_class))
File &quot;/home/kamal/go_appengine/google/appengine/api/yaml_listener.py&quot;, line 177, in _HandleEvents
raise yaml_errors.EventError(e, event_object)
google.appengine.api.yaml_errors.EventError: Unknown url handler type.
URLMap 
auth_fail_action=redirect 
static_dir=None 
secure=default 
http_headers=None 
url=/.* 
static_files=None 
expiration=None 
upload=None 
api_endpoint=None 
script=None 
application_readable=None 
position=None 
login=optional 
mime_type=None 
require_matching_file=None
in &quot;myapp/app.yaml&quot;, line 8, column 1
error while running dev_appserver.py: exit status 1

I don't know how to debug it. Just a hint would be sufficient.
Also, can it be because I have no web server installed? Do I have to install Apache or Nginx for goapp serve or go handles the server stuff itself?

答案1

得分: 3

问题是在.yaml文件的handlers中的script的缩进问题。
我最初是这样做的:

handlers:
  - url: /.*
    script: _go_app

而实际上应该是:

handlers:
  - url: /.*
    script: _go_app

现在它可以正常工作了!

英文:

The problem was indentation of script in handlers in .yaml file.
I initially did it like this:

handlers:
  - url: /.*
    script: _go_app

While it should be:

handlers:
  - url: /.*
    script: _go_app

It works now!

huangapple
  • 本文由 发表于 2014年4月19日 16:53:57
  • 转载请务必保留本文链接:https://go.coder-hub.com/23167958.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定