如何过滤掉定期请求

时间:2014-12-30 19:15:59

标签: python django openshift

enter image description here

我使用django在openshift.com上部署了一个网站。每次请求时,我都会将ip地址和请求时间保存到表中。我正在看桌子,我看到上面的截图。我不确定这里到底发生了什么。显然,我的网站在每小时10点钟的时候被抓住了。我认为这是基于https://stackoverflow.com/questions/27672042/http-method-head-on-my-openshift-server-received-every-hour的正常行为。但是,我想从openshift过滤掉这些假定的请求,以便我只看到用户请求该网站的时间。这是最好的方法吗?

在django我正在使用:

def index(request):

    from ipware.ip import get_ip
    ip = get_ip(request)
    ....
    (save to table)

1 个答案:

答案 0 :(得分:1)

我会创建一个包含您要忽略的条目/ ips的表。 或者如果您认为它不会发生太大变化,那么我们只需要一个变量

def index(request):

    from ipware.ip import get_ip
    ip = get_ip(request)
    ....
    if ip not in LIST
        (save to table)

或者您可以在dtabase / table上使用一些过滤器逻辑(取决于您用来保存数据的内容?)

相关问题