当前位置: 首页>>代码示例>>Python>>正文


Python flask_ask.Ask方法代码示例

本文整理汇总了Python中flask_ask.Ask方法的典型用法代码示例。如果您正苦于以下问题:Python flask_ask.Ask方法的具体用法?Python flask_ask.Ask怎么用?Python flask_ask.Ask使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask_ask的用法示例。


在下文中一共展示了flask_ask.Ask方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: init_blueprint

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import Ask [as 别名]
def init_blueprint(self, blueprint, path='templates.yaml'):
        """Initialize a Flask Blueprint, similar to init_app, but without the access
        to the application config.

        Keyword Arguments:
            blueprint {Flask Blueprint} -- Flask Blueprint instance to initialize (Default: {None})
            path {str} -- path to templates yaml file, relative to Blueprint (Default: {'templates.yaml'})
        """
        if self._route is not None:
            raise TypeError("route cannot be set when using blueprints!")

        # we need to tuck our reference to this Ask instance into the blueprint object and find it later!
        blueprint.ask = self

        # BlueprintSetupState.add_url_rule gets called underneath the covers and
        # concats the rule string, so we should set to an empty string to allow
        # Blueprint('blueprint_api', __name__, url_prefix="/ask") to result in
        # exposing the rule at "/ask" and not "/ask/".
        blueprint.add_url_rule("", view_func=self._flask_view_func, methods=['POST'])
        blueprint.jinja_loader = ChoiceLoader([YamlLoader(blueprint, path)]) 
开发者ID:johnwheeler,项目名称:flask-ask,代码行数:22,代码来源:core.py

示例2: setUp

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import Ask [as 别名]
def setUp(self):
        self.app = Flask(__name__)
        self.app.config['ASK_VERIFY_REQUESTS'] = False
        self.ask = Ask(app=self.app, route='/ask')
        self.client = self.app.test_client()

        @self.ask.intent('TestCustomSlotTypeIntents')
        def custom_slot_type_intents(child_info):
            return statement(child_info) 
开发者ID:johnwheeler,项目名称:flask-ask,代码行数:11,代码来源:test_integration_support_entity_resolution.py

示例3: setUp

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import Ask [as 别名]
def setUp(self):
        self.ask_patcher = patch('flask_ask.core.find_ask', return_value=Ask())
        self.ask_patcher.start()
        self.context_patcher = patch('flask_ask.models.context', return_value=MagicMock())
        self.context_patcher.start() 
开发者ID:johnwheeler,项目名称:flask-ask,代码行数:7,代码来源:test_audio.py

示例4: test_setting_and_getting_current_stream

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import Ask [as 别名]
def test_setting_and_getting_current_stream(self):
        ask = Ask()
        with patch('flask_ask.core.find_ask', return_value=ask):
            self.assertEqual(_Field(), ask.current_stream)
        
            stream = _Field()
            stream.__dict__.update({'token': 'asdf', 'offsetInMilliseconds': 123, 'url': 'junk'})
            with patch('flask_ask.core.top_stream', return_value=stream):
                self.assertEqual(stream, ask.current_stream) 
开发者ID:johnwheeler,项目名称:flask-ask,代码行数:11,代码来源:test_audio.py

示例5: test_from_directive_call

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import Ask [as 别名]
def test_from_directive_call(self):
        ask = Ask()
        fake_stream = _Field()
        fake_stream.__dict__.update({'token':'fake'})
        with patch('flask_ask.core.top_stream', return_value=fake_stream):
            from_buffer = ask._from_directive()
            self.assertEqual(fake_stream, from_buffer) 
开发者ID:johnwheeler,项目名称:flask-ask,代码行数:9,代码来源:test_audio.py

示例6: find_ask

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import Ask [as 别名]
def find_ask():
    """
    Find our instance of Ask, navigating Local's and possible blueprints.

    Note: This only supports returning a reference to the first instance
    of Ask found.
    """
    if hasattr(current_app, 'ask'):
        return getattr(current_app, 'ask')
    else:
        if hasattr(current_app, 'blueprints'):
            blueprints = getattr(current_app, 'blueprints')
            for blueprint_name in blueprints:
                if hasattr(blueprints[blueprint_name], 'ask'):
                    return getattr(blueprints[blueprint_name], 'ask') 
开发者ID:johnwheeler,项目名称:flask-ask,代码行数:17,代码来源:core.py

示例7: init_app

# 需要导入模块: import flask_ask [as 别名]
# 或者: from flask_ask import Ask [as 别名]
def init_app(self, app, path='templates.yaml'):
        """Initializes Ask app by setting configuration variables, loading templates, and maps Ask route to a flask view.

        The Ask instance is given the following configuration variables by calling on Flask's configuration:

        `ASK_APPLICATION_ID`:

            Turn on application ID verification by setting this variable to an application ID or a
            list of allowed application IDs. By default, application ID verification is disabled and a
            warning is logged. This variable should be set in production to ensure
            requests are being sent by the applications you specify.
            Default: None

        `ASK_VERIFY_REQUESTS`:

            Enables or disables Alexa request verification, which ensures requests sent to your skill
            are from Amazon's Alexa service. This setting should not be disabled in production.
            It is useful for mocking JSON requests in automated tests.
            Default: True

        `ASK_VERIFY_TIMESTAMP_DEBUG`:

            Turn on request timestamp verification while debugging by setting this to True.
            Timestamp verification helps mitigate against replay attacks. It relies on the system clock
            being synchronized with an NTP server. This setting should not be enabled in production.
            Default: False

        `ASK_PRETTY_DEBUG_LOGS`:

            Add tabs and linebreaks to the Alexa request and response printed to the debug log.
            This improves readability when printing to the console, but breaks formatting when logging to CloudWatch.
            Default: False
        """
        if self._route is None:
            raise TypeError("route is a required argument when app is not None")

        self.app = app
        
        app.ask = self

        app.add_url_rule(self._route, view_func=self._flask_view_func, methods=['POST'])
        app.jinja_loader = ChoiceLoader([app.jinja_loader, YamlLoader(app, path)]) 
开发者ID:johnwheeler,项目名称:flask-ask,代码行数:44,代码来源:core.py


注:本文中的flask_ask.Ask方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。