gpt4 book ai didi

time - CouchDB:通过 CouchApp 中的 http 请求获取服务器时间

转载 作者:行者123 更新时间:2023-12-04 19:19:14 25 4
gpt4 key购买 nike

我需要 CouchApp 中“用户在线”统计信息的服务器时间。我使用 jquery.couch.js 并且更喜欢有一个 url,例如/db/_design/app/time - 这给我一个时间戳。
我如何意识到这一点?

最佳答案

一个 show 函数可以做到这一点:

function(doc, req) {
// _design/myapp/_show/now

// First version possibly incompatible with some spidermonkey versions.
//var now = new Date();
var now = new Date().getTime();
var output = JSON.parse(JSON.stringify(now)) + "\n";

return { code: 200
, headers: { "Content-Type": "text/plain"
}
, body:output
};
}

服务器还包括一个 Date您可能想要使用的 header 。
$ curl -D- http://localhost:5984
HTTP/1.1 200 OK
Server: CouchDB/1.1.0 (Erlang OTP/R14B)
Date: Fri, 27 May 2011 00:28:31 GMT
Content-Type: text/plain;charset=utf-8
Content-Length: 40
Cache-Control: must-revalidate

{"couchdb":"Welcome","version":"1.1.0"}

关于time - CouchDB:通过 CouchApp 中的 http 请求获取服务器时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6136028/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com