japronto icon indicating copy to clipboard operation
japronto copied to clipboard

POST Params paring issue

Open ifightcode opened this issue 7 years ago • 3 comments

I was trying to extract POST parameters from requests and failed. What I've tried

#In Router
app.router.add_route('/add', add, method='POST')
#In Function
# Add url to database
def add(request):
    #try:
        db = request.mongo
        url = request.match_dict['url']
        key = request.match_dict['key']

And I'm getting error

File "in.py", line 41, in add
    url = request.match_dict['url']
KeyError: 'url'

Any idea how to get things functional?

ifightcode avatar Oct 10 '17 13:10 ifightcode

Try This

def basic(request):
    test=request.query['name']

nishankmahore avatar Nov 13 '17 13:11 nishankmahore

Try this

def basic(request): test = request.form['name']

sahibzadafahad99 avatar Feb 08 '18 04:02 sahibzadafahad99

def auth(request):
      post = app.getPost(request)
      print(post)

def getPost(req):
        list  = req.body.decode('utf-8').split('&')
        post = {}
        for item in list:
            p = item.split('=')
            post[p[0]]=p[1]
        return post

     result is : {'username': 'vadim', 'password': '123'}

I did it this way

vadim-shadrin avatar May 11 '18 17:05 vadim-shadrin