路径中的Python Azure Apps 404

时间:2019-07-06 11:25:58

标签: python azure flask

我遵循了Create a Python app in Azure App Service on Linux,并使用以下功能上传了我的代码:

@app.route('/predict_json', methods=['POST'])
def add_message():
    content = request.json

    tweets = pd.DataFrame(content)
    tweets["polarity"] = pipeline.predict(tweets.Tweet)   

    return tweets.to_json()

@app.route('/predict')
def predict():
    # Retrieve query parameters related to this request.
    content = request.args.get('content')    

    d = {'tweet': [content]}
    df = pd.DataFrame(data=d)

    # Use the model to predict the class
    label_index = pipeline.predict(df.tweet)
    # Retrieve the iris name that is associated with the predicted class
    label = MODEL_LABELS[label_index[0]]
    label_int = MODEL_INT[label_index[0]]
    # Create and send a response to the API caller
    return jsonify(status='complete',tweet=content, polarity=label_int, polarity_text=label)

在本地,它们工作完美。但是部署后我得到了404。

我的代码在https://github.com/mulflar/saturdayAi/blob/master/twitteranalisisdesentimientosnlp.py

1 个答案:

答案 0 :(得分:0)

您可以尝试

  • twitteranalisisdesentimientosnlp.py重命名为app.py

OR

  • 由于主应用程序文件未命名为app.py或application.py,因此您需要指定启动时要运行的命令(有关更多信息,请参见this doc)。在这种情况下,将是:
gunicorn --bind=0.0.0.0 --timeout 600 twitteranalisisdesentimientosnlp:app #The :app corresponds to the name of the flask app inside of the file