mirror of https://github.com/r4sas/py-i2phosts
Browse Source
Done by zzz request. Export all seen hosts in json format { b32: last_seen }.pull/1/head
Hidden Z
11 years ago
4 changed files with 22 additions and 0 deletions
@ -0,0 +1,5 @@
@@ -0,0 +1,5 @@
|
||||
from django.conf.urls import * |
||||
|
||||
urlpatterns = patterns('pyi2phosts.api.views', |
||||
url(r'^all/$', 'all'), |
||||
) |
@ -0,0 +1,16 @@
@@ -0,0 +1,16 @@
|
||||
import simplejson as json |
||||
|
||||
from django.http import HttpResponse |
||||
|
||||
from pyi2phosts.postkey.models import i2phost |
||||
from pyi2phosts.lib.utils import get_b32 |
||||
|
||||
def all(request): |
||||
"""Return all hosts in { "b32": "last seen timestamp" } form. Implemented by zzz request. """ |
||||
# all hosts seen at least once |
||||
queryset = i2phost.objects.exclude(last_seen=None) |
||||
json_dict = {} |
||||
for host in queryset: |
||||
# pass last_seen to json in unixtime |
||||
json_dict[get_b32(host.b64hash)] = host.last_seen.strftime("%s") |
||||
return HttpResponse(json.dumps(json_dict), mimetype="application/json") |
Loading…
Reference in new issue