开发者

Output html from CouchDB list

开发者 https://www.devze.com 2023-01-06 16:11 出处:网络
I am trying to create a list in CouchDB 0.11 which responds with some html, I am having problems getting CouchDB to set the correct header, whatever I try, I just get an application/json response head

I am trying to create a list in CouchDB 0.11 which responds with some html, I am having problems getting CouchDB to set the correct header, whatever I try, I just get an application/json response header. Here is my list function.

function(head, req) {

    var rows = [];
    var row;

    while(row = getRow()) {
        rows.push(row);
    }

    rows.sort(function(a, b) {
        return (Date.parse(a['value']['last_logtime']) - Date.parse(b['value']['last_logtime']));
    });

    provides("html", function() {
        var content = "<html><head><title>foobar</title></head><body>";
        for(var i in rows) {
            content = content + rows[i]['value']['last_logtime']+"<br/>";
        }
        content = content + "</body></html>";
        retu开发者_如何转开发rn content;
    });

}

Any suggestions what I am doing wrong?


well actually figured it out myself.

the getRow() stuff needs to be inside the provides function :)

0

精彩评论

暂无评论...
验证码 换一张
取 消