简体   繁体   English

TemplateNotFound:将网站部署在Google App Engine上但在本地主机中运行时网站运行正常时,templates / HomePage.html错误

[英]TemplateNotFound: templates/HomePage.html error when website is deployed on Google app engine but the website run fine when ran in local host

I am trying to deploy my personal website but I am running into a big error when I run my website in local host everything runs fine.But I have deployed my website via Google App but it does not work. 我正在尝试部署我的个人网站,但是当我在本地主机上运行我的网站时,我遇到了一个大错误。但是我已经通过Google App部署了我的网站,但无法正常工作。 I keep getting this error below Here is a screenshot of the error I get 我一直在下面收到此错误, 这是我收到的错误的屏幕截图

I don't know why it is doing this because that Homepage.html file is inside of the template folder. 我不知道为什么要这样做,因为该Homepage.html文件位于模板文件夹中。 This a screenshot of my file path and the Python code I wrote . 这是我的文件路径和我编写的Python代码的屏幕截图 This the code I wrote 这是我写的代码

import jinja2
import os
import webapp2
import logging
from google.appengine.api import users
from google.appengine.ext import ndb
import datetime
import json
import unicodedata
from google.appengine.api import users

 # the two lines of code below makes the jinja work
jinja_environment = jinja2.Environment(loader=
    jinja2.FileSystemLoader(os.path.dirname(__file__)))

class HomePage(webapp2.RequestHandler):
    def get(self):
        template = 
jinja_environment.get_template('templates/HomePage.html')
        self.response.write(template.render())

class AboutMe(webapp2.RequestHandler):
    def get(self):
        template = jinja_environment.get_template('templates/Aboutme.html')
        self.response.write(template.render())

class Contact(webapp2.RequestHandler):
    def get(self):
        template = jinja_environment.get_template('templates/Contact.html')
        self.response.write(template.render())


class Projects(webapp2.RequestHandler):
    def get(self):
    template = 
jinja_environment.get_template('templates/Projects.html')
        self.response.write(template.render())

app = webapp2.WSGIApplication([
    ('/', HomePage), #HomePage
    ('/AboutMe.html',AboutMe),
    ('/Contact.html',Contact),
    ('/Projects.html',Projects)

], debug=True)
}

here is my app.yaml file 这是我的app.yaml文件

application: israel-ali
version: 1
runtime: python27
api_version: 1
threadsafe: yes
# order matters always have this order
handlers:
- url: /favicon\.ico
  static_files: favicon.ico
  upload: favicon\.ico

- url: /resources
  static_dir: static_folder

- url: .*
  script: main.app

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

[enter image description here][3] [在此处输入图片描述] [3]

Filenames are case sensitive on GAE. 文件名在GAE上区分大小写。

Your code seeks a template called HomePage.html and (what I suspect to be) the actual template is called Homepage.html . 您的代码将查找一个名为HomePage.html的模板,并且(我怀疑是)实际的模板名为Homepage.html And you have a similar problem with Aboutme.html vs. AboutMe.html . 而且, Aboutme.htmlAboutMe.html也有类似的问题。

You just need to use the actual filename in .get_template() . 您只需要在.get_template()使用实际的文件名。

Is the operating system you're using locally one that doesn't treat case in filenames as significant? 您正在本地使用的操作系统不会将文件名中的大小写视为重要吗? If so, those template_get lines need to specify filenames exactly as they are on the filesystem. 如果是这样,则这些template_get行需要完全按照文件系统上的名称指定文件名。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 现有的HTML网站,但在Google App Engine上处理? - Existing HTML website, but processing on Google App Engine? 要在Google App Engine上托管静态(HTML)网站,app.yaml文件中应包含哪些内容? - To host a static (HTML) website on Google App Engine, what should be in the app.yaml file? TemplateNotFound:带有Google App Engine和Jinja2的index.html - TemplateNotFound: index.html with Google App Engine & Jinja2 将网站链接到Google App Engine - Linking a website to Google App Engine 在谷歌应用引擎上部署 flask 应用和 SQLite 时的缓存问题 - Caching issue when deployed flask app with SQLite on google App engine 从 html 按钮运行 python 脚本时出现 404 错误 | 托管 Google App Engine 网站 - 404 error running python script from html button | Google App Engine website hosted 运行程序时无法在 chrome 上显示网站 - Unable to display website on chrome when ran the program 完全迷路了。 程序在本地对html进行100%的解析,但是从App Engine运行时失败 - Completely lost. Program parses html 100% fine locally, but fails when run from App Engine 代码可在localhost上运行,但在使用Google App Engine进行部署时无法运行 - Code working on localhost, but not working when deployed using Google App Engine App Engine部署后会出现数字格式错误 - App Engine gives error in number formatting when deployed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM