Flask服务器未在AWS Elastic Beanstalk上运行

时间:2019-02-12 09:33:35

标签: python amazon-web-services flask amazon-ec2 amazon-elastic-beanstalk

我正在尝试在AWS Elastic beantalk上部署我的flask应用程序。托管的Web应用程序的链接为here。但是,只有在我的本地服务器打开时,它才起作用。它在控制台中显示的警告为Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:5000/hi. (Reason: CORS request did not succeed).

我已允许所有入站流量,如此处“ image所示。 烧瓶的代码如下:

application = app = Flask(__name__)
CORS(app)

@app.route("/")
def showHome():
    return render_template('index.html')


@app.route("/<msg>")
def helloWorld(msg):
  print(msg)
  CLIENT_ACCESS_TOKEN = "*********************"
  ai = apiai.ApiAI(CLIENT_ACCESS_TOKEN)
  req = ai.text_request()
  req.lang = 'de'
  req.session_id = "<SESSION ID, UNIQUE FOR EACH USER>"
  req.query = msg
  response = req.getresponse()
  reader = codecs.getreader("utf-8")
  answerJSON = json.load(reader(response))
  answer = answerJSON['result']['fulfillment']['speech']
  if str.lower(str(answer)).find('registered')!=-1:
    return (answer+button)
  if answer == "I haven't got your query. Please, make sure you have clearly stated your problem/query?":
    return (answer+button)
  return (answer)


if __name__=='__main__':
    app.run(host="0.0.0.0")

帮助我解决问题。

0 个答案:

没有答案
相关问题