在Google App Engine Python中提供静态html

如何解决在Google App Engine Python中提供静态html

| 我无法为Python加载静态
.html
页面 应用程式。当我单击类似index.html的链接时,出现空白页,并且在服务器上记录404错误。其他静态“ 0”文件(例如about.html)也是如此。 该应用程序可以阻止静态文件。我试着看 很多地方,但我似乎无法使.html页面最多。即   INFO 2011-04-16 17:26:33,655 dev_appserver.py:3317] \“获取/   terms.html HTTP / 1.1 \“ 404- yaml:
application: quote
version: 1
runtime: python
api_version: 1

handlers:

- url: /index\\.html
script: index.py

- url: /
script: index.py

- url: /(.*\\.(html))
static_files: static/\\1
upload: static/HTML/(.*\\.(html))


- url: /favicon.ico
static_files: static/images/favicon.ico
upload: images/favicon.ico
mime_type: image/x-icon

- url: /css
static_dir: static/css

- url: /images
static_dir: static/images

- url: /js
static_dir: static/js
我的静态文件位于static / HTML中,而index.html位于主文件夹中。 我也尝试过此方法,但似乎完全没有区别:
- url: /favicon.ico
  static_files: static/images/favicon.ico
  upload: images/favicon.ico
  mime_type: image/x-icon

- url: /css
  static_dir: static/css

- url: /images
  static_dir: static/images

 - url: /js
  static_dir: static/js

 - url: /(.*\\.(html))
  static_files: static/\\1
  upload: static/HTML/(.*\\.(html))

 - url: /index\\.html
  script: index.py

 - url: /
 script: index.py
    

解决方法

将您的HandlerScript保持在“静态目录”处理部分的下面。 IOW,将其移至最后。
- url: /index\\.html
script: index.py

- url: /
script: index.py
    ,在您的static_files路径中放入ѭ5:
- url: /(.*\\.(html))
  static_files: static/HTML/\\1
  upload: static/HTML/(.*\\.(html))
    ,您不必在yaml文件中单独定义每个目录
handlers:
- url: /static
  static_dir: my_application/static
然后在将要用django渲染的相关html文件中,您可以调用静态内容,例如
<script src=\"/static/less_lib.min.js\"></script>
    ,您必须正确缩进您的YAML。 提供 脚本级别不正确
handlers:
- url: /index\\.html
script: index.py
相当于json
{
  \"handlers\": [
    {
      \"url\": \"/index\\\\.html\"
    }
  ],\"script\": \"index.py\"
}
缩进 正确级别的脚本
handlers:
- url: /index\\.html
  script: index.py
相当于json
{
  \"handlers\": [
    {
      \"url\": \"/index\\\\.html\",\"script\": \"index.py\"
    }
  ]
}
在线YAML解析器     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其他元素将获得点击?
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。)
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbcDriver发生异常。为什么?
这是用Java进行XML解析的最佳库。
Java的PriorityQueue的内置迭代器不会以任何特定顺序遍历数据结构。为什么?
如何在Java中聆听按键时移动图像。
Java“Program to an interface”。这是什么意思?