Я пытаюсь получить данные из URL, используя метод get в flask и python, но получаю
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)