problem with flask ask
@ask.launch issue
am having problem running my python flask script. I am using python 2.7, the error says: File "C:\Users\user1\AppData\Local\Continuum\anaconda2\Lib\site-packages\hello_lumion.py", line 13, in @ask.launch NameError: name 'ask' is not defined
import logging
import os
from flask import request
from flask import Flask
from flask_ask import Ask, statement, request, context, session, question, version
import requests
@ask.launch
def welcome():
return statement ('Welcome to Foo')
app = Flask(__name__)
ask= Ask(app,"/")
logging.getLogger("flask_ask").setLevel(logging.DEBUG)
@ask.intent("Hello")
def hello():
msg= "hello from lumion"
return statement (msg)
if __name__ == '__main__':
port = 9000
app.run(host='0.0.0.0', port=port)
app.run(debug=True)
any advice on how to overcome this issue?
You are calling ask
before it is defined. In your code you have
@ask.launch # ask has not been made
def welcome():
return statement ('Welcome to Foo')
app = Flask(__name__)
ask= Ask(app,"/") # ask gets made here!
You will need to reorder it so when you call ask
, it has been defined. Something like:
app = Flask(__name__)
ask= Ask(app,"/") # define it first
@ask.launch # now use it
def welcome():
return statement ('Welcome to Foo')