PUT options do not work in python / google engine.

I am working on a simple RESTful web service with python with a webapp map in google engine.

Basically I send the whole request through AJAX / jquery - for POST it works like a charm, but when I send data using PUT, the parameters are empty / not processed.

this is my put:

    $.ajax({
        type: "PUT",
        url: "/boxes",
        data: { name: this.name, archived: this.archived  },
        success: function(msg){
        }
    });

firebug said i put:

Parameter   application/x-www-form-urlencoded
archived    false
name    123112323asdasd

but using this python code:

from google.appengine.ext import webapp
from google.appengine.ext.webapp import util, template
from google.appengine.ext import db
from google.appengine.api.datastore_types import *
from django.utils import simplejson as json

import cgi
import datetime

class BoxHandler(webapp.RequestHandler):

def post(self): #working
    print "test"
    self.response.out.write(self.request.get("name"))

def put(self):
    print "test" #not working
    self.response.out.write(self.request.get("name"))

just return

test
Status: 200 OK
Content-Type: text/html; charset=utf-8
Cache-Control: no-cache
Expires: Fri, 01 Jan 1990 00:00:00 GMT
Content-Length: 0

So .. hm, is there anything I am missing here?

amuses, Martin

+3
source share
1 answer

put , , , test; , , , webob.

request.body, .

def put(self):
    print "test"
    name = parse_body_to_extract_your_parameter(self.request.body)
    self.response.out.write(name)
+4

Source: https://habr.com/ru/post/1782190/


All Articles