将Unity WebPlayer应用程序上传到Google App Engine会出现500服务器错误

时间:2013-11-20 03:40:40

标签: python google-app-engine unity3d

我正在参与Google App Challenge,但我无法让应用程序在appspot域名网站上运行。我正在使用Python来部署应用程序。需要帮助

app.yaml文件详细信息如下所示

application: abhicorp111
version: 1
runtime: python27
api_version: 1
threadsafe: yes

handlers:


- url: /WebPlayer\.unity3d
  static_files: WebPlayer/WebPlayer.unity3d
  upload: WebPlayer/WebPlayer\.unity3d

- url: .*
  script: main.app

libraries:
- name: webapp2
  version: "2.5.2"

The main.py content

#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
from google.appengine.ext.webapp import template
import webapp2
import os

class MainHandler(webapp2.RequestHandler):
def get(self):

template_values = {
'greetings': 'greetings',
}
path = os.path.join('WebPlayer', 'WebPlayer.html')
self.response.out.write(template.render(path, template_values))



app = webapp2.WSGIApplication([
    ('/', MainHandler)
], debug=True)

从命令行更新后获取500服务器错误enter image description here 应用程序的文件夹结构 enter image description here 我得到的错误 enter image description here 我通过GAE日志控制台上传错误日志

> 2013-11-20 09:27:34 Running command: "['C:\\Python27\\python.exe',
> 'C:\\Program Files (x86)\\Google\\google_appengine\\dev_appserver.py',
> '--skip_sdk_update_check=yes', '--port=15080', '--admin_port=8007',
> u'E:\\GAEGame\\WebPlayer']" INFO     2013-11-20 09:27:35,315
> devappserver2.py:660] Skipping SDK update check. WARNING  2013-11-20
> 09:27:35,331 api_server.py:327] Could not initialize images API; you
> are likely missing the Python "PIL" module. WARNING  2013-11-20
> 09:27:35,588 simple_search_stub.py:1009] Could not read search indexes
> from
> c:\users\santu\appdata\local\temp\appengine.abhicorp111\search_indexes
> INFO     2013-11-20 09:27:35,648 api_server.py:138] Starting API
> server at: http://localhost:4755 INFO     2013-11-20 09:27:35,674
> dispatcher.py:168] Starting module "default" running at:
> http://localhost:15080 INFO     2013-11-20 09:27:35,700
> admin_server.py:117] Starting admin server at: http://localhost:8007
> ERROR    2013-11-20 03:57:44,651 wsgi.py:262] 
> 
> Traceback (most recent call last):
> 
>   File "C:\Program Files
> (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line
> 239, in Handle
> 
>     handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
> 
>   File "C:\Program Files
> (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line
> 298, in _LoadHandler
> 
>     handler, path, err = LoadObject(self._handler)
> 
>   File "C:\Program Files
> (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line
> 84, in LoadObject
> 
>     obj = __import__(path[0])
> 
>   File "E:\GAEGame\WebPlayer\main.py", line 22
> 
>     def get(self):
> 
>       ^
> 
> IndentationError: expected an indented block
> 
> INFO     2013-11-20 09:27:44,663 module.py:599] default: "GET /
> HTTP/1.1" 500 - ERROR    2013-11-20 03:57:44,697 wsgi.py:262] 
> 
> Traceback (most recent call last):
> 
>   File "C:\Program Files
> (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line
> 239, in Handle
> 
>     handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
> 
>   File "C:\Program Files
> (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line
> 298, in _LoadHandler
> 
>     handler, path, err = LoadObject(self._handler)
> 
>   File "C:\Program Files
> (x86)\Google\google_appengine\google\appengine\runtime\wsgi.py", line
> 84, in LoadObject
> 
>     obj = __import__(path[0])
> 
>   File "E:\GAEGame\WebPlayer\main.py", line 22
> 
>     def get(self):
> 
>       ^
> 
> IndentationError: expected an indented block
> 
> INFO     2013-11-20 09:27:44,710 module.py:599] default: "GET
> /favicon.ico HTTP/1.1" 500 -

更新并完成错误然后启动服务器后,我收到此消息 这是从另一个文件夹完成的,然后我调用了python的appserver启动命令

C:\Windows\system32>dev_appserver.py E:\ed23\WebPlayer1
INFO     2013-11-20 13:25:04,336 sdk_update_checker.py:245] Checking for updates
 to the SDK.
WARNING  2013-11-20 13:25:06,148 api_server.py:327] Could not initialize images
API; you are likely missing the Python "PIL" module.
WARNING  2013-11-20 13:25:06,641 simple_search_stub.py:1009] Could not read sear
ch indexes from c:\users\santu\appdata\local\temp\appengine.enginerite11\search_
indexes
INFO     2013-11-20 13:25:06,688 api_server.py:138] Starting API server at: http
://localhost:20091
INFO     2013-11-20 13:25:06,713 dispatcher.py:168] Starting module "default" ru
nning at: http://localhost:8080
INFO     2013-11-20 13:25:06,742 admin_server.py:117] Starting admin server at:
http://localhost:8000
ERROR    2013-11-20 07:58:37,220 webapp2.py:1552] WebPlayer1.html
Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2
.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2
.py", line 1529, in __call__
    rv = self.router.dispatch(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2
.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2
.py", line 1102, in __call__
    return handler.dispatch()
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2
.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2
.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "E:\ed23\WebPlayer1\main.py", line 28, in get
    self.response.out.write(template.render(path, template_values))
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\weba
pp\template.py", line 89, in render
    t = _load_internal_django(template_path, debug)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\weba
pp\template.py", line 163, in _load_internal_django
    template = django.template.loader.get_template(file_name)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\_interna
l\django\template\loader.py", line 157, in get_template
    template, origin = find_template(template_name)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\_interna
l\django\template\loader.py", line 138, in find_template
    raise TemplateDoesNotExist(name)
TemplateDoesNotExist: WebPlayer1.html
INFO     2013-11-20 13:28:37,285 module.py:599] default: "GET / HTTP/1.1" 500 24
09
INFO     2013-11-20 13:28:37,497 module.py:599] default: "GET /favicon.ico HTTP/
1.1" 200 1150
ERROR    2013-11-20 08:03:19,309 webapp2.py:1552] WebPlayer1.html
Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2
.py", line 1535, in __call__
    rv = self.handle_exception(request, response, e)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2
.py", line 1529, in __call__
    rv = self.router.dispatch(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2
.py", line 1278, in default_dispatcher
    return route.handler_adapter(request, response)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2
.py", line 1102, in __call__
    return handler.dispatch()
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2
.py", line 572, in dispatch
    return self.handle_exception(e, self.app.debug)
  File "C:\Program Files (x86)\Google\google_appengine\lib\webapp2-2.5.2\webapp2
.py", line 570, in dispatch
    return method(*args, **kwargs)
  File "E:\ed23\WebPlayer1\main.py", line 28, in get
    self.response.out.write(template.render(path, template_values))
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\weba
pp\template.py", line 89, in render
    t = _load_internal_django(template_path, debug)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\ext\weba
pp\template.py", line 163, in _load_internal_django
    template = django.template.loader.get_template(file_name)
INFO     2013-11-20 13:33:19,326 module.py:599] default: "GET / HTTP/1.1" 500 24
09
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\_interna
l\django\template\loader.py", line 157, in get_template
    template, origin = find_template(template_name)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\_interna
l\django\template\loader.py", line 138, in find_template
    raise TemplateDoesNotExist(name)
TemplateDoesNotExist: WebPlayer1.html
INFO     2013-11-20 13:33:19,427 module.py:599] default: "GET /favicon.ico HTTP/
1.1" 304 -

2 个答案:

答案 0 :(得分:1)

main.py有语法错误(缩进不正确)。您需要缩进def get(self):并进一步缩进get方法中所属的代码。那就是

> IndentationError: expected an indented block

试图告诉你。

我建议在上传之前让您的应用在dev_appserver本地运行。这将缩短开发周期时间。

答案 1 :(得分:-1)

从错误日志中:

Could not initialize images API; you are likely missing the Python "PIL" module.

您需要为您的应用程序配置PIL。在文档的configuring third party libraries部分,将以下内容添加到app.yaml

libraries:
- name: PIL
  version: latest

接下来,您的代码本身存在一些基本问题。 Python对whitepace敏感,并且块内的任何语句都需要缩进,这就是你得到这个错误的原因:

  

文件“E:\ GAEGame \ WebPlayer \ main.py”,第22行

def get(self):

  ^
     

IndentationError:预期缩进块

块内的所有语句都需要缩进;通常的做法是缩进四个空格(不是制表符)。这是你的代码,正确缩进:

from google.appengine.ext.webapp import template
import webapp2
import os

class MainHandler(webapp2.RequestHandler):
    def get(self):
        template_values = {
            'greetings': 'greetings',
        }
        path = os.path.join('WebPlayer', 'WebPlayer.html')
        self.response.out.write(template.render(path, template_values))



app = webapp2.WSGIApplication([
    ('/', MainHandler)
], debug=True)