gpt4 book ai didi

路径中的 Python Azure 应用程序 404

转载 作者:行者123 更新时间:2023-12-03 16:55:46 24 4
gpt4 key购买 nike

我关注了这个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

最佳答案

你可以尝试一下

  • twitteranalisisdesentimientosnlp.py 重命名为 app.py

或者

  • 由于您的主应用程序文件不名为 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

关于路径中的 Python Azure 应用程序 404,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56913659/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com