jinja2.exceptions.templatenotfound:results.html

tjrkku2a  于 2021-09-08  发布在  Java
关注(0)|答案(0)|浏览(233)

我已经在我的电脑上运行了这段代码,它运行得很好。但当我将其部署到zyte时,它会引发一个错误。它似乎无法访问模板和sqlite文件。
目录
setup.py


# Automatically created by: shub deploy

from setuptools import setup, find_packages

setup(
    name         = 'project',
    version      = '1.0',
    packages     = find_packages(),
    entry_points = {'scrapy': ['settings = gumtree.settings']},
)
New/   
    .scrapy/crawl_once/gumtree.splite  
    gumtree/              
        __init__.py
        items.py  
        middlewares.py
        models.py
        pipelines.py      
        settings.py       

        spiders/           
            __init__.py
            example.py
    templates/
       base.html
       results.html
    __init__.py
    requirements.txt
    scrapinghub.yml

错误

Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/twisted/internet/defer.py",line 654, in _runCallbacks
        current.result = callback(current.result, *args,**kw)
File "/app/__main__.egg/gumtree/pipelines.py", line 91, in close_spider
File "/app/__main__.egg/gumtree/pipelines.py", line 123, in send_mail
File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 883, in get_template
        return self._load_template(name, self.make_globals(globals))
File "/usr/local/lib/python3.8/site-packages/jinja2/environment.py", line 857, in _load_template
        template = self.loader.load(self, name, globals)
File "/usr/local/lib/python3.8/site-packages/jinja2/loaders.py", line 117, in load
        source, filename, uptodate = self.get_source(environment, name)
File "/usr/local/lib/python3.8/site-packages/jinja2/loaders.py", line 199, in get_source
        raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: results.html

代码

file_loader = jinja2.FileSystemLoader('templates')
env = jinja2.Environment(loader=file_loader)
template = env.get_template('results.html')
mail_content = template.render(items=self.items)
print(mail_content)

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题