【问题标题】:Batch file creation to execute POST method in Flask API (windows)在 Flask API (windows) 中创建批处理文件以执行 POST 方法
【发布时间】:2019-04-27 03:48:41
【问题描述】:

我必须创建一个批处理文件,以便它调用以下 API POST 方法并在 Windows 上无缝执行它。这里不需要向 POST 方法提供任何输入

这适用于 API 调用的 ML 模块。我尝试通过批处理文件和 anaconda 提示符直接调用提到的模块,但这不能正常工作。

import CLassName1
from flask import Flask

app=Flask(__name__)

@app.route('/api/model/testing', methods=['POST'])
def test_model():
     response=ClassName1.method_name1()
     return response

@app.route('/test')
def post_health():
     return "health"

if __name__ == '__main__':
     app.run(host='127.0.0.1',port=15010, debug=True)

预计会运行 method_name1 和后续方法,然后填充另一个文件 - 在父文件夹中创建的“输出”。

实际上 - 当 method_name1 直接从 anaconda 提示符执行时,一段时间后会引发 Import 错误并不断循环

【问题讨论】:

    标签: python-3.x rest api flask


    【解决方案1】:

    您能否分享您在调用 method_name1() 时得到的确切错误堆栈跟踪,因为只要 method_name1() 返回字符串或 method_name1() 中没有错误,此代码应该运行。

    【讨论】:

    • 由于一些隐私问题,我无法提供堆栈跟踪,但是当我通过 API 进行调用时,一切正常;这意味着该函数没有任何错误。唯一的事情是我想知道如何从批处理文件中调用 POST 方法 API(这里的 POST 方法不需要任何输入)您的任何帮助都会有所帮助
    猜你喜欢
    • 2012-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-23
    • 2016-02-05
    • 2013-09-25
    相关资源
    最近更新 更多