python - 在 Google 应用引擎 Python 中提供静态 html

标签 python html google-app-engine yaml

我无法为我的 Python 加载静态 .html 页面 应用程序。当我点击像 index.html 这样的链接时,我得到一个空白页面并且在服务器上记录了 404 错误。这与其他静态 .html 文件(例如 about.html)相同。

应用程序可以运行静态文件。我试着看看 很多地方,但我似乎无法打开 .html 页面。即

INFO 2011-04-16 17:26:33,655 dev_appserver.py:3317] "GET / 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

最佳答案

将您的 HandlerScripts 保持在静态目录处理部分之下。 IOW,把这个移到最后。

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

- url: /
script: index.py

关于python - 在 Google 应用引擎 Python 中提供静态 html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5693976/

相关文章:

javascript - 如何自动调整弹出窗口或模式对话框的大小以进行内容更改

python - POST 请求正文中删除了换行符? (谷歌应用引擎)

python - 在python pandas中添加组列的百分比

python - 如何检查两个文件名是否相似并选择最新版本

python - 在 python 中定义 2 个函数时出现语法错误

python - 如何在谷歌应用引擎上使用html5上传多个文件(python)

google-app-engine - GAE/standard/second/Python 上的 Spacy 超出了最大实例的内存

python - 如何在 Python 2 中将字符串转换为字节

javascript - jquery remove 只影响第一个跨度

Jquery 阻止链接但保留 url anchor