Python bottle accept data send by jquery
Question: I'm using Python bottle, html/css, and Javascript to develop a website. Now in
the Javascript part, I want to send a list data to the back end Python using
Jquery:

    
    
    $.ajax({
                type: "POST",
                url: '/deleteauthor',
                data: keys,
                success: function() {
                for (var i=0, n=checkboxes.length; i<n; ++i)
                    if (checkboxes[i].checked==true) {
                        var id = "#" + checkboxes[i].value;
                        $(id).hide();
                    }
                }
            });
    

In the Python bottle side, how can I receive the the data?


Answer: Something like:

    
    
    from bottle import route, run, request
    @route('/deleteauthor', method='POST')
    def index():
        request.body.seek(0)
        data = request.body.read()
        #do something with data
    
    run(host='localhost', port=8080, debug=True)
    

