2017-09-07 35 views
2

我试图部署我的个人网站,但运行我的网站时遇到了一个大错误在本地主机中一切运行良好。但我已通过Google应用部署了我的网站,但它不起作用。我不断收到此错误Here is a screenshot of the error I getTemplateNotFound:在Google应用引擎上部署网站时出现模板/ HomePage.html错误,但在本地主机上运行时网站运行良好

我不知道为什么它这样做是因为该Homepage.html文件位于模板文件夹内。 This a screenshot of my file path and the Python 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) 
} 

这里是我的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" 

[在这里输入的形象描述] [3]

+0

请粘贴代码,而不仅仅是代码的图像。 – DIF

+0

更好吗? – Izzy

+0

欢迎来到SO!回溯也是如此 - 除非图像包含相关的视觉信息,否则不要发布文字图像。 –

回答

2

文件名是区分在GAE敏感。

您的代码寻找一个名为HomePage.html的模板,并且(我怀疑是)实际模板名为Homepage.html。而且你也有类似的问题Aboutme.htmlAboutMe.html

您只需要使用.get_template()中的实际文件名。

2

您在本地使用的操作系统是不是将文件名中的大小写视为重要的操作系统?如果是这样,那些template_get行需要指定文件名,正如,因为它们在文件系统上。

+0

谢谢,我修复了我的错误。 – Izzy

相关问题