request.args and request.content from curl
sugizo opened this issue · 1 comments
sugizo commented
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