Problems with the solictud Post made python from a form made in laravel

2

I have a form made in laravel done with the method POST which is the following

<form method="POST">    
{{ csrf_field() }}

    <input type="email" name="email">   
    <input type="password" name="password">     
    <input type="submit" value="ingresar" >

 </form>

But when I want to access a request post with python using the library 'urllib, which the code is as follows:

import urllib2
import urllib

while 1:

    url = "http://192.168.1.10/login"
    query_args = { 'email':'[email protected]','password':'123456'}
    data =urllib.urlencode(query_args)
    request = urllib2.Request (url,data)
    response = urllib2.urlopen(request).read()
    print response

I get the following error:

  

File "urlx2.py", line 10, in            response = urllib2.urlopen (request) .read ()

     

File "/usr/lib/python2.7/urllib2.py", line 154, in urlopen            return opener.open (url, data, timeout)

     

File "/usr/lib/python2.7/urllib2.py", line 437, in open            response = meth (req, response)

     

File "/usr/lib/python2.7/urllib2.py", line 550, in http_response            'http', request, response, code, msg, hdrs)

     

File "/usr/lib/python2.7/urllib2.py", line 475, in error            return self._call_chain (* args)

     

File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain            result = func (* args)

     

File "/usr/lib/python2.7/urllib2.py", line 558, in http_error_default            raise HTTPError (req.get_full_url (), code, msg, hdrs, fp)       urllib2.HTTPError: HTTP Error 500: Internal Server Error

All is correctly. I think it's a problem of CSRF_TOKEN of Laravel , since it works correctly with the solictud GET without the CSRF_TOKEN . I do not think it's the problem with the request POST , since I've done it with a Form done in PHP and works correctly.

How could you implement that Solitude POST with URLLIB of PYTHON

    
asked by CESAR NICOLINI RIVER 01.05.2017 в 06:16
source

0 answers