小编典典

Google App Engine:不会提供以下错误的静态资产:

css

Google在这种情况下没有用,似乎我是第一个遇到此错误的人:/在我的Mac上运行良好,但是在尝试请求CSS之类的静态资产时,在Windows
8绑定中使用相同的文件会在日志中显示以下错误文件和图像。这是错误的代码段:

INFO     2014-06-08 14:42:28,431 module.py:639] default: "GET /css/rootStyles.css HTTP/1.1" 200 5454
ERROR    2014-06-08 14:42:28,431 module.py:714] Request to '/css/rootStyles.css' failed
Traceback (most recent call last):
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\module.py", line 710, in _handle_request
    return handler.handle(match, environ, wrapped_start_response)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\static_files_handler.py", line 369, in handle
    return self._handle_path(full_path, environ, start_response)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\static_files_handler.py", line 182, in _handle_path
    start_response('200 OK', headers)
  File "C:\Program Files (x86)\Google\google_appengine\google\appengine\tools\devappserver2\module.py", line 640, in wrapped_start_response
    return start_response(status, response_headers, exc_info)
  File "C:\Program Files (x86)\Google\google_appengine\lib\cherrypy\cherrypy\wsgiserver\wsgiserver2.py", line 2155, in start_response
    raise TypeError("WSGI response header value %r is not of type str." % v)
TypeError: WSGI response header value u'text/css' is not of type str.
INFO     2014-06-08 14:42:28,433 module.py:639] default: "GET /css/rootStyles.css HTTP/1.1" 500 -

我的app.yml文件如下所示:

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

handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico
- url: /img
  static_dir: img
- url: /font
  static_dir: font
- url: /css
  static_dir: css

- url: .*
  script: main.app

libraries:
- name: webapp2
  version: "2.5.2"
- name: jinja2
  version: latest

阅读 241

收藏
2020-05-16

共1个答案

小编典典

在GAE的问题跟踪器中启动了一个错误。
id=11001同时,该线程上comme#4中的临时补丁有效。

google\appengine\tools\devappserver2\static_files_handler.py

line 166, 167, 168, need add str to self._get_mime_type(full_path)

if user_headers.Get('Content-type') is None:
    #headers.append(('Content-type', self._get_mime_type(full_path)))<br />
    headers.append(('Content-type', str(self._get_mime_type(full_path))))<br /><br />
    # 2014-06-09 fix on Win7 "TypeError: WSGI response header value u'text/html' is not of type str"
2020-05-16