If I have a specific link in my sinatra, for instance say /requests, how can I monitor the number of times the page is loaded. Ideally, I want to be able to get a hit count for how many times a specific page on my server is accessed. Thanks.
问问题
282 次
1 回答
1
There are number of ways to do this. For example, you could add a filters which can log this.
To log the request you can use file system, database, etc. Something like below.
#filter to intercept request to URL
before '/requests' do
log_request
end
# Helper function to write
def log_request
# Actual logic to write to file system or database
end
于 2013-09-18T11:08:11.353 回答