gpt4 book ai didi

python - TopLevelLookupException : Can not locate template for uri

转载 作者:行者123 更新时间:2023-12-01 05:50:09 31 4
gpt4 key购买 nike

当我想启动我的 Pyramid 服务器时,它返回 TopLevelLookupException: Can not located template for uri 错误。请解释一下问题出在哪里

from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
from pyramid.view import view_config
import tweepy
import os

consumer_key=""
consumer_secret=""
access_key = ""
access_secret = ""
here = os.path.dirname(os.path.abspath(__file__))

也许,问题出在这个“这里”对象上。

def twitterfeed(request):
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)
api = tweepy.API(auth)
statuses = tweepy.Cursor(api.friends_timeline).items(20)
data = Response('\n'.join([s.text.encode('utf8') for s in statuses]))
print type(data)
return {"data": data}


if __name__ == '__main__':
settings = {}
settings['reload_all'] = True
settings['debug_all'] = True
settings['mako.directories'] = os.path.join(here, 'templates')
config = Configurator()
config.add_view(twitterfeed, route_name='list', renderer='list.mako')
config.add_route('list', '/')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 8000, app)
server.serve_forever()

最佳答案

感谢@swietyy,我的代码现在可以运行了

def twitterfeed(request):
auth = tweepy.OAuthHandler(consumer_key, consumer_secret)
auth.set_access_token(access_key, access_secret)
api = tweepy.API(auth)
statuses = tweepy.Cursor(api.friends_timeline).items(20)
data = [s.text.encode('utf8') for s in statuses]
return {"data": data}
#...
#...
#...
config = Configurator(settings=settings)

关于python - TopLevelLookupException : Can not locate template for uri,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14588047/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com