我有下一个代码:
from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
import tweepy
consumer_key=""
consumer_secret=""
access_key = ""
access_secret = ""
def twitterfeed():
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)
for status in statuses:
return list(str(status.text))
这个 twitterfeed() 方法正在 bash/console 上运行,并显示我和我的订阅者的最新推文。但是当我想在页面上显示这条推文时:
if __name__ == '__main__':
config = Configurator()
config.add_route('hello', '{name}')
config.add_view(twitterfeed(), route_name='hello')
app = config.make_wsgi_app()
server = make_server('0.0.0.0', 8080, app)
server.serve_forever()
它向我显示pyramid.exceptions.ConfigurationExecutionError: <type 'exceptions.AttributeError'>: 'list' object has no attribute '__module__'
in:
Line 24
错误
我该如何解决?如果你有来自 django 的工作示例,它可以帮助我。