[英]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.html
与AboutMe.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.