使用 flask-ask 和 ngrok 进行 Alexa 技能开发 [英] Alexa Skill Development using flask-ask and ngrok

查看:25
本文介绍了使用 flask-ask 和 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: module '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:Python36libsite-packagesflaskapp.py", line 1997, in __call__
    return self.wsgi_app(environ, start_response)
  File "C:Python36libsite-packagesflaskapp.py", line 1985, in wsgi_app
    response = self.handle_exception(e)
  File "C:Python36libsite-packagesflaskapp.py", line 1540, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "C:Python36libsite-packagesflask\_compat.py", line 33, in reraise
    raise value
  File "C:Python36libsite-packagesflaskapp.py", line 1982, in wsgi_app
    response = self.full_dispatch_request()
  File "C:Python36libsite-packagesflaskapp.py", line 1614, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "C:Python36libsite-packagesflaskapp.py", line 1517, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "C:Python36libsite-packagesflask\_compat.py", line 33, in reraise
    raise value
  File "C:Python36libsite-packagesflaskapp.py", line 1612, in full_dispatch_request
    rv = self.dispatch_request()
  File "C:Python36libsite-packagesflaskapp.py", line 1598, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "C:Python36libsite-packagesflask_askcore.py", line 728, in _flask_view_func
    ask_payload = self._alexa_request(verify=self.ask_verify_requests)
  File "C:Python36libsite-packagesflask_askcore.py", line 662, in _alexa_request
    cert = verifier.load_certificate(cert_url)
  File "C:Python36libsite-packagesflask_askverifier.py", line 21, in load_certificate
    if not _valid_certificate(cert):
  File "C:Python36libsite-packagesflask_askverifier.py", line 63, in _valid_certificate
    value = str(extension)
  File "C:Python36libsite-packagesOpenSSLcrypto.py", line 779, in __str__
    return self._subjectAltNameString()
  File "C:Python36libsite-packagesOpenSSLcrypto.py", line 740, in _subjectAltNameString
    method = _lib.X509V3_EXT_get(self._extension)
AttributeError: module 'lib' has no attribute 'X509V3_EXT_get'

点冻结输出:

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)

这篇关于使用 flask-ask 和 ngrok 进行 Alexa 技能开发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆