stats.py 文件源码

python
阅读 21 收藏 0 点赞 0 评论 0

项目:rankedftw 作者: andersroos 项目源码 文件源码
def get(self, request, mode_id=None):
        mode_id = int(mode_id)
        if not (mode_id in Mode.stat_v1_ids):
            return HttpResponse(status=404)

        last_updated = to_unix(cache_value("ranking_stats_last_modified", 600, ranking_stats_last_modified))
        now = to_unix(utcnow())

        try:
            if_modified_since = parse_http_date(request.META['HTTP_IF_MODIFIED_SINCE'])
        except (ValueError, KeyError):
            if_modified_since = 0

        if if_modified_since >= last_updated:
            response = HttpResponse("", content_type="application/json", status=304)
        else:
            response = HttpResponse(cache_value("ranking_stats_%d" % mode_id, 600,
                                                rankings_view_client, 'ranking_stats', mode_id),
                                    content_type="application/json")

        response['Cache-Control'] = "max-age=86400"
        response['Date'] = http_date(now)
        response['Expires'] = http_date(now + 86400)
        response['Last-Modified'] = http_date(last_updated)
        return response
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号