【问题标题】:Unity3d - Hosting on Google App EngineUnity3d - 在 Google App Engine 上托管
【发布时间】:2011-09-12 16:23:13
【问题描述】:

我在 GAE 上托管 Unity3d Web 应用程序时遇到问题。 当应用程序加载并且网络播放器开始请求 ".unity3d" 文件时,我使用以下 python 脚本进行 HTTP 响应:

class UnityHandler(webapp.RequestHandler):
  def get (self, q):
    if q is None:
      q = 'WebPlayer.unity3d'

path = os.path.join (os.path.dirname (__file__), q)
self.response.headers ['Content-Type'] = 'text/html'
self.response.out.write (template.render (path, {}))

def main ():
  application = webapp.WSGIApplication (
    [('/(.*html)?', MainHandler), 
    ('/(.*unity3d)?', UnityHandler)
    ], debug=True)
  util.run_wsgi_app (application)

它不能很好地工作,它找到了文件,但是 Unity 网络播放器给了我一个“错误的文件长度”错误。

那么谁能告诉我问题出在哪里? 我认为这与设置“内容类型”有关,但我不知道如何解决?

谢谢,

萨默·萨米

【问题讨论】:

    标签: python google-app-engine unity3d


    【解决方案1】:

    首先,我假设您要缩进以 path = 开头的 3 行。

    其次,我猜您的意图是将 url“/”路由到 WebPlayer.unity3d。但是,您的两个正则表达式都将匹配 / 因为斜杠之后的所有内容都是可选的; MainHandler 将收到请求,因为它是第一个。

    第三,您似乎不仅要通过动态处理程序而且还通过模板引擎来提供静态文件。为什么?如果您只是想逐字提供静态文件,请使用 static handlers

    假设您已将 .unity3d 文件放在名为 static 的目录中:

    # render WebPlayer.unity3d on /
    - url: /
      static_files: static/WebPlayer.unity3d
      upload: static/WebPlayer.unity3d
    
    # match other .unity3d files
    - url: /(.*\.unity3d)
      static_files: static/\1
      upload: static/(.*\.unity3d)
    
    # match *.html and anything else
    - url: .*
      script: main.py
    

    【讨论】:

    • 谢谢,它确实有效,我使用了这样的东西:handlers: # match .unity3d files - url: /(static/webplayer.unity3d) static_files: static/webplayer.unity3d upload: static/webplayer.unity3d mime_type: application/vnd.unity
    猜你喜欢
    • 2010-10-19
    • 2020-09-05
    • 1970-01-01
    • 2021-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-02
    • 2016-02-15
    相关资源
    最近更新 更多