路径中的Python Azure Apps 404 - python

我遵循此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

从Azure Data Factory执行python脚本 - python

有人可以帮我从Azure数据工厂执行python函数吗?我已经将python函数存储在blob中,并且我试图触发同样的功能。但是我无法做到这一点。请协助。第二,我可以从ADF参数化python函数调用吗? python参考方案 您可能会发现ADF中的Azure Function Activity概念,它允许您在Data Factory管道中运行Azure F…

Python sqlite3数据库已锁定 - python

我在Windows上使用Python 3和sqlite3。我正在开发一个使用数据库存储联系人的小型应用程序。我注意到,如果应用程序被强制关闭(通过错误或通过任务管理器结束),则会收到sqlite3错误(sqlite3.OperationalError:数据库已锁定)。我想这是因为在应用程序关闭之前,我没有正确关闭数据库连接。我已经试过了: connectio…

Python-Excel导出 - python

我有以下代码:import pandas as pd import requests from bs4 import BeautifulSoup res = requests.get("https://www.bankier.pl/gielda/notowania/akcje") soup = BeautifulSoup(res.cont…

Python:传递记录器是个好主意吗? - python

我的Web服务器的API日志如下:started started succeeded failed 那是同时收到的两个请求。很难说哪一个成功或失败。为了彼此分离请求,我为每个请求创建了一个随机数,并将其用作记录器的名称logger = logging.getLogger(random_number) 日志变成[111] started [222] start…

Python pytz时区函数返回的时区为9分钟 - python

由于某些原因,我无法从以下代码中找出原因:>>> from pytz import timezone >>> timezone('America/Chicago') 我得到:<DstTzInfo 'America/Chicago' LMT-1 day, 18:09:00 STD…