Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用python编写GET函数_Python_Http_Flask - Fatal编程技术网

使用python编写GET函数

使用python编写GET函数,python,http,flask,Python,Http,Flask,我正在开发一个Python应用程序并使用flask。 我现在正在编写GET函数。 以下是它的工作原理: GET http://{host_ip}:{port}/GetMessage?applicationId=1 GET http://{host_ip}:{port}/GetMessage?sessionId=aaaa GET http://{host_ip}:{port}/GetMessage?messageId=bbbb 这是我的密码: @app.route('/GetMessage')

我正在开发一个Python应用程序并使用flask。 我现在正在编写GET函数。 以下是它的工作原理:

GET http://{host_ip}:{port}/GetMessage?applicationId=1
GET http://{host_ip}:{port}/GetMessage?sessionId=aaaa
GET http://{host_ip}:{port}/GetMessage?messageId=bbbb
这是我的密码:

@app.route('/GetMessage')
def GetMessage():
    application_id = request.args.get('application_id')
    messages = Message.query.filter_by(user_id=application_id) 
    return render_template('get.html', messages=messages)

@app.route('/GetMessage')
def GetMessage():
    message_id = request.args.get('message_id')
    messages = Message.query.filter_by(message_id=message_id) 
    return render_template('get.html', messages=messages)
但它给了我这样一个错误信息:

AssertionError: View function mapping is overwriting an existing endpoint function: GetMessage
可以做些什么?
谢谢

不能两次声明同一路径
def GetMessage():
    messages = Message.query.all()
    application_id = request.args.get('application_id')
    if application_id:
        messages.filter_by(user_id=application_id)

    message_id = request.args.get('message_id')
    if message_id:
        messages = message.filter_by(message_id=message_id)  
    return render_template('get.html', messages=messages)