Skip to content

Instantly share code, notes, and snippets.

@johnsheehan
Created March 31, 2012 22:18
Show Gist options
  • Save johnsheehan/2269053 to your computer and use it in GitHub Desktop.
Save johnsheehan/2269053 to your computer and use it in GitHub Desktop.
@app.route('/xyzzy/ajax/<resource>', methods=['POST', 'GET', 'DELETE'])
@auth.required
@https_required
def admin_ajax(resource):
cmd = Command(request.method, resource)
# could replace this with data = request.params
data = request.args
if (request.method in ['PUT', 'POST']):
data = request.form
result, status = cmd.execute(data)
resp = make_response(json.dumps(result), status)
resp.headers['Content-Type'] = 'application/json'
return resp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment