Sam*_*nen 4 google-app-engine content-type static-files http-headers app.yaml
我曾多次尝试为从Google App Engine提供的静态文件定义字符集,并且失败了.
文件在文件的标题部分中包含正确的元等效标记:
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
Run Code Online (Sandbox Code Playgroud)
但它并没有作为标题传递,浏览器需要从实际文档中获取它.
当然,如果我使用脚本(或Python Google App Engine程序),那么我可以将它作为响应标头正确传递.
Content-Type: text/html; charset=UTF-8
Run Code Online (Sandbox Code Playgroud)
我试图添加到app.yaml文件行:
- url: /
static_files: root/create.html
upload: root/create.html
http_headers:
Content-Type: text/html; charset=UTF-8
Run Code Online (Sandbox Code Playgroud)
但是appcfg.py告诉我:对于URLMap类型的对象,出现了意外的属性"http_headers".在"9oxnet/app.yaml"第41行第5栏中
要修复静态文件的此charset头问题,您需要在app.yaml文件中定义charset:
- url: /
static_files: root/create.html
upload: root/create.html
mime_type: text/html; charset=UTF-8
Run Code Online (Sandbox Code Playgroud)
现在,静态文件的Content-Type标头也正确包含字符集信息.
Content-Type: text/html; charset=UTF-8
Run Code Online (Sandbox Code Playgroud)
如果标题中未包含字符集信息,则某些浏览器不会尽快解析页面.
归档时间: |
|
查看次数: |
1077 次 |
最近记录: |