【问题标题】:Requested url not found on server error在服务器错误上找不到请求的 url
【发布时间】:2014-02-02 10:55:40
【问题描述】:

我创建了一个网站,我暂时在应用引擎中托管。当我在计算机上打开 HTML 文件时,我可以浏览页面。只有当我前往 http://www.alshafarconstruction.appspot.com/index.html 时它才会失败。

错误信息:

Error: Not Found

The requested URL /contact.html was not found on this server

app.yaml:

application: alshafarnew
version: 1
runtime: python
api_version: 1

handlers:
- url: /(.*\.(gif|png|jpg|ico|js|css|swf|xml))
  static_files: \1
  upload: (.*\.(gif|png|jpg|ico|js|css|swf|xml))

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

- url: /.*
  script: main.py

ma​​in.py:

from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app

class IndexHandler(webapp.RequestHandler):
    def get(self):
        if self.request.url.endswith('/'):
            path = '%sindex.html'%self.request.url

        self.redirect(path)

    def post(self):
        self.get()

application = webapp.WSGIApplication([('/.*', IndexHandler)], debug=True)

def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()

我检查了仪表板,发现 HTML 文件在那里。我是网站部署和设计的新手。任何人都可以提出可能的错误吗?我已经访问了许多网站以寻求解决方案。

【问题讨论】:

  • 在仪表板中,是否有contact.html 页面的预览链接?如果你点击它,你会得到什么URL
  • 粘贴你的 app.yaml 可能是个好主意,因为它可以管理路由等。
  • @PaulCollingwood 已将其发布为我的问题的更新
  • @NickR Iam 能够打开仪表板,但你能告诉我在哪里可以获得详细信息
  • 你缺少的东西。在您的 app.yaml 中,您的处理程序应该已经处理了 index.html 的任何页面。你上传了应用程序吗?

标签: python html google-app-engine web web-deployment


【解决方案1】:

The documentation 暗示静态文件和应用程序文件是分开上传的,因此虽然文件可能在那里,但它们可能是在应用程序文件部分上传的。

您目前有一个 upload 指令告诉它只上传 index.html

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

(其实是正则表达式,所以也会上传,比如index@html如果存在的话)
这表明您可能希望使该正则表达式匹配所有 HTML 文件:

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

【讨论】:

  • 你的意思是我必须用你在下面给出的代码更改 App 文件
  • @sreenathsreenath:是的;您需要更改app.yaml,以便与HTML 文件对应的部分具有upload 属性.*\.html
  • 谢谢你把我从地狱里救了出来……现在可以了,谢谢兄弟
猜你喜欢
  • 1970-01-01
  • 2017-09-09
  • 1970-01-01
  • 1970-01-01
  • 2021-04-11
  • 2013-05-22
  • 2018-04-19
  • 2017-10-31
相关资源
最近更新 更多