extensions.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:whisper 作者: bovarysme 项目源码 文件源码
def init_app(self, app):
        consumer_key = app.config.get('TWITTER_CONSUMER_KEY')
        consumer_secret = app.config.get('TWITTER_CONSUMER_SECRET')
        access_token = app.config.get('TWITTER_ACCESS_TOKEN')
        access_token_secret = app.config.get('TWITTER_ACCESS_TOKEN_SECRET')

        if not all([consumer_key, consumer_secret, access_token, access_token_secret]):
            raise RuntimeError(
                'At least one of the following configuration values was not '
                'set: TWITTER_CONSUMER_KEY, TWITTER_CONSUMER_SECRET, '
                'TWITTER_ACCESS_TOKEN, TWITTER_ACCESS_TOKEN_SECRET.'
            )

        auth = tweepy.auth.OAuthHandler(consumer_key, consumer_secret)
        auth.set_access_token(access_token, access_token_secret)

        api = tweepy.API(auth)
        app.extensions['tweepy'] = api
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号