使用烧瓶询问和ngrok的Alexa技能开发

编程入门 行业动态 更新时间:2024-10-04 13:20:52
本文介绍了使用烧瓶询问和ngrok的Alexa技能开发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正尝试在python中使用flask-ask和ngrok开发一种Alexa技能。以下是我的代码:

I'm trying to begin developing a skill for alexa using flask-ask and ngrok in python. Following is my code:

from flask import Flask from flask_ask import Ask, statement, question, session import json import requests import time import unidecode app = Flask(__name__) ask = Ask(app, "/reddit_reader") def get_headlines(): titles = 'is this working' return titles @app.route('/') def homepage(): return "hi there, how ya doin?" @ask.launch def start_skill(): welcome_message = 'Hello there, would you like the news?' return question(welcome_message) @ask.intent("YesIntent") def share_headlines(): headlines = get_headlines() headline_msg = 'The current world news headlines are {}'.format(headlines) return statement(headline_msg) @ask.intent("NoIntent") def no_intent(): bye_text = 'I am not sure why you asked me to run then, but okay... bye' return statement(bye_text) if __name__ == '__main__': app.run(debug=True)

代码在我的机器上运行良好,如果我将其打印,则返回正确的输出出来。但是,当我使用ngrok将其部署到亚马逊上时,该技能会产生HTTP 500内部错误。在开发控制台中的文本以及json模拟器中,我都得到了500个内部错误。

The code runs fine on my machine and returns the correct output if I print it out. But the skill gives a HTTP 500 internal error when I deploy it on amazon using ngrok. I get the same 500 internal error both in the text as well as json simulator in the development console.

这是我的意图模式:

{ "intents": [ { "intent": "YesIntent" }, { "intent": "NoIntent" } ] }

我在python提示符中收到以下错误: AttributeError:模块'lib'没有属性'X509V3_EXT_get

I get the following error in my python prompt: AttributeError: module 'lib' has no attribute 'X509V3_EXT_get

堆栈跟踪如下:

Traceback (most recent call last): File "C:\Python36\lib\site-packages\flask\app.py", line 1997, in __call__ return self.wsgi_app(environ, start_response) File "C:\Python36\lib\site-packages\flask\app.py", line 1985, in wsgi_app response = self.handle_exception(e) File "C:\Python36\lib\site-packages\flask\app.py", line 1540, in handle_exception reraise(exc_type, exc_value, tb) File "C:\Python36\lib\site-packages\flask\_compat.py", line 33, in reraise raise value File "C:\Python36\lib\site-packages\flask\app.py", line 1982, in wsgi_app response = self.full_dispatch_request() File "C:\Python36\lib\site-packages\flask\app.py", line 1614, in full_dispatch_request rv = self.handle_user_exception(e) File "C:\Python36\lib\site-packages\flask\app.py", line 1517, in handle_user_exception reraise(exc_type, exc_value, tb) File "C:\Python36\lib\site-packages\flask\_compat.py", line 33, in reraise raise value File "C:\Python36\lib\site-packages\flask\app.py", line 1612, in full_dispatch_request rv = self.dispatch_request() File "C:\Python36\lib\site-packages\flask\app.py", line 1598, in dispatch_request return self.view_functions[rule.endpoint](**req.view_args) File "C:\Python36\lib\site-packages\flask_ask\core.py", line 728, in _flask_view_func ask_payload = self._alexa_request(verify=self.ask_verify_requests) File "C:\Python36\lib\site-packages\flask_ask\core.py", line 662, in _alexa_request cert = verifier.load_certificate(cert_url) File "C:\Python36\lib\site-packages\flask_ask\verifier.py", line 21, in load_certificate if not _valid_certificate(cert): File "C:\Python36\lib\site-packages\flask_ask\verifier.py", line 63, in _valid_certificate value = str(extension) File "C:\Python36\lib\site-packages\OpenSSL\crypto.py", line 779, in __str__ return self._subjectAltNameString() File "C:\Python36\lib\site-packages\OpenSSL\crypto.py", line 740, in _subjectAltNameString method = _lib.X509V3_EXT_get(self._extension) AttributeError: module 'lib' has no attribute 'X509V3_EXT_get'

Pip冻结输出:

aniso8601==1.2.0 asn1crypto==0.24.0 certifi==2018.1.18 cffi==1.11.5 chardet==3.0.4 click==6.7 cryptography==2.2 Flask==0.12.1 Flask-Ask==0.9.8 idna==2.6 itsdangerous==0.24 Jinja2==2.10 MarkupSafe==1.0 pycparser==2.18 pyOpenSSL==17.0.0 python-dateutil==2.7.0 PyYAML==3.12 requests==2.18.4 six==1.11.0 Unidecode==1.0.22 urllib3==1.22 Werkzeug==0.14.1

我尝试在python 2.7和python 3.6上运行它。感谢您的任何帮助

I've tried running it on both python 2.7 and python 3.6. Any help is appreciated

推荐答案

遇到同样的问题,您可以通过将加密技术降级到2.2以下来解决此问题。

Ran into the same issue, you can fix it by downgrading cryptography to anything less than 2.2 for me.

pip install 'cryptography<2.2'

rpg711获得所有功劳(请参见原始帖子的评论)

rpg711 gets all the credit (see comments the on original post)

更多推荐

使用烧瓶询问和ngrok的Alexa技能开发

本文发布于:2023-11-28 03:24:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1640767.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:烧瓶   技能   ngrok   Alexa

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!