twisted/klein

request.args and request.content from curl

sugizo opened this issue · 1 comments

api.py

@app.route('/api/put/<tablename>/<rec_id>', methods = ['PUT'] )
def put(request, tablename, rec_id):
    import json
    if request.args:
        raw = '{0}'.format(request.args)
        json_dumps = json.dumps(raw)
        json_loads_raw = json.loads(raw)
        json_loads_dumps = json.loads(json_dumps)
        values = raw.replace("\'", "\"")
    elif request.content:
        values = json.loads(request.content.read() )
    row = db(db[tablename]._id == rec_id).validate_and_update(**values) 
    db.commit()
    return row.as_dict()

result
various error traceback occured

objective
can update table from below command

curl -X PUT -i "http://localhost:8000/api/put/instrument/2?name=name0&strings=0"
curl -X PUT -d "name=name1&strings=1" -i http://localhost:8000/api/put/instrument/2

question
how to achieve it using klein way ?

thanks

@sugizo This isn't really a bug report so much as a question. Please try Stack Overflow unless you think there's a bug in Klein, in which case we need a description; we don't provide user support here.