为什么我在Flask python中使用get方法时遇到错误

问题描述 投票:-1回答:1

我试图通过在flask和python中使用get方法从url获取数据但是获取

192.168.0.128 - - [22/Feb/2019 16:40:18] "TypeError: 'list' object is not callable
The view function did not return a valid response. The return type must be a string, tuple, Response instance, or WSGI callable, but it was a list.
192.168.0.128 - - [22/Feb/2019 16:51:39] "GET /autocomplete?input=%27mumbai%27 HTTP/1.1" 500 -

url:http://192.168.0.128:5000/autocomplete?input=%27mumbai%27

脚本:

app = Flask(__name__)
#cors = CORS(app)
cors = CORS(app, resources={r"/foo": {"origins": "http://localhost:port"}})

app.config['CORS_HEADERS'] = 'Content-Type'

@app.route('/autocomplete', methods=['GET']) 
@cross_origin(origin='localhost',headers=['Content- Type','Authorization'])
def AutoComplete():

    data = request.args.get('input')
    print (data)

    #http://192.168.0.128:5000/autocomplete=?input=mumbai

    spellchecker = SpellChecker()
    tokens = spellchecker.correct_phrase(data)
    result = AutoCompleter().guess_exercises(tokens)

    return result[:10]


if __name__ == '__main__':
    app.run(host='192.168.0.128', port=5000)
python python-3.x flask-restful
1个回答
1
投票

发回给您的错误。那个错误是错误404

来自维基百科:强调HTTP 404,404 Not Found和404错误消息是计算机网络通信中的超文本传输​​协议(HTTP)标准响应代码,用于指示客户端能够与给定服务器通信,但服务器无法找到所要求的内容。

尝试将请求从/autocomplete/更改为/autocomplete

© www.soinside.com 2019 - 2024. All rights reserved.