【问题标题】:Uploading Unity WebPlayer app to Google App Engine getting 500 server error将 Unity WebPlayer 应用程序上传到 Google App Engine 得到 500 服务器错误
【发布时间】:2013-11-20 16:19:53
【问题描述】:

我正在参加 Google 应用挑战赛,但我无法让应用在 apppot 域网站上运行。我正在使用 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 服务器错误 应用程序的文件夹结构 我得到的错误 我通过 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 -

【问题讨论】:

  • 你记录的错误是什么。

标签: python google-app-engine unity3d


【解决方案1】:

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

> IndentationError: expected an indented block

想告诉你。

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

【讨论】:

    【解决方案2】:

    来自错误日志:

    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 对空白很敏感,任何进入块内的语句都需要缩进,这就是您收到此错误的原因:

    文件“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)
    

    【讨论】:

    • 这是一个非常常见的警告,在这里不是问题。
    猜你喜欢
    • 2020-02-20
    • 1970-01-01
    • 2015-03-18
    • 2012-07-25
    • 1970-01-01
    • 1970-01-01
    • 2017-12-28
    • 2021-06-07
    • 1970-01-01
    相关资源
    最近更新 更多