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)
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.
This is my intent schema:
{
"intents": [
{
"intent": "YesIntent"
},
{
"intent": "NoIntent"
}
]
}
I get the following error in my python prompt:
AttributeError: module 'lib' has no attribute 'X509V3_EXT_get
The stacktrace is as follows:
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 freeze output:
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
I've tried running it on both python 2.7 and python 3.6. Any help is appreciated
pip freeze
and paste that output as well. – Shrivecryptography
to version 1.7 and see if that fixes this, pyOpenSSL requires 1.7 at a minimum, something may have been removed in the new cryptography module that the older v17.0.0 pyOpenSSL depends on. – Shrive