flask post request and get request

148 Views Asked by At

Friends

I am using get request in flask and sending parameters in url only https://127.0.0.1:34/CheckOn?parameter1=abc&parameter2=deq

accessing the parameters using parser = reqparse.RequestParser() parser.add_argument('parameter1', type=str)

Now for post I want to pass these parameters in the request url only and access it using method other than reqparse.RequestParser() http://127.0.0.1:123/messages?new123=1234

Need to access new123 with method other than RequestParser

1

There are 1 best solutions below

0
Matías Zanolli On

No matter if you're using either GET or POST methods, you can get your URL parameters through Flask's request.args dictionary.

In your case it would be something like:

from flask import request

@app.route('/CheckOn')
def check_on():
    parameter1 = request.args.get('parameter1') # abc
    parameter2 = request.args.get('parameter2') # deq