烧瓶的问题
@ask.launch问题
我在运行python flask脚本时遇到问题。我使用的是Python2.7,错误显示:文件"C:\Users\user1\AppData\Local\Continuum\anaconda2\Lib\site-packages\hello_lumion.py",第13行,在@ask.launch NameError中:未定义名称'ask‘
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) 对于如何克服这个问题,有什么建议吗?
发布于 2019-05-07 01:20:42
在定义ask之前,您正在调用它。在你的代码中,你有
@ask.launch # ask has not been made
def welcome():
return statement ('Welcome to Foo')
app = Flask(__name__)
ask= Ask(app,"/") # ask gets made here!您将需要对其重新排序,以便当您调用ask时,它已被定义。类似于:
app = Flask(__name__)
ask= Ask(app,"/") # define it first
@ask.launch # now use it
def welcome():
return statement ('Welcome to Foo')https://stackoverflow.com/questions/56009705
复制相似问题