将JSON正文发布到Flask应用程序,引发“500内部服务器错误”

2024-06-16 11:31:32 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在appengine Flex上托管我的Flask应用程序。我正在尝试向我的应用程序发布一个包含一些JSON的请求。当我尝试执行此操作时,会出现“500内部服务器错误”。你知道吗

@app.route('/input', methods=['POST','GET'])
def input():
    if request.method == 'POST':
        kpi = request.json['kpi']
        hanaview = request.json['source']
        first_property = request.json['startnode']['first_property']
        first_value = request.json['startnode']['first_value']
        filters = request.json['filters']
        filters['CalMonth'] = tuple(filters['CalMonth'])
        progression = request.json['progression']
        alert_tree = get(kpi, hanaview, filters, progression, first_property, first_value, compare=lambda x: x < 10 and x > -10)
        tree = alert_tree.get_tree()
        return jsonify(tree)
    if request.method == 'GET':
        return "this is a GET request"

我可以在当地毫无问题地解决这个问题,有人能告诉我为什么会这样吗?你知道吗

JSON码:

{
    "kpi": "MarketSharePercentCD",
    "source": "MarketShareFSet",
    "startnode": {
        "first_property": "Division",
        "first_value": "GE"
    },
    "filters": {
        "CalYear" :  2019,
        "CalMonth" : [4,5],
        "ManufacturerDescription": "test"
    },
    "progression": [
        "CategoryDescription"
    ]
}

错误消息:

ConnectionError: HTTPConnectionPool(host='URL', port=8000): Max retries exceeded with url: URL (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f5039cb0a50>: Failed to establish a new connection: [Errno -2] Name or service not known',))

Tags: jsontree应用程序getvaluerequest错误property