This commit is contained in:
guange 2019-01-22 14:26:05 +08:00
parent 8d21fc09e3
commit b28758032f
2 changed files with 4 additions and 2 deletions

View File

@ -2,6 +2,7 @@ import json
from django.http import HttpResponse
from myapp.models import *
from myapp.utils import get_platform_info
from django.core.serializers import serialize
def _render_json(data):
response = HttpResponse(json.dumps(data, ensure_ascii=False),
@ -10,7 +11,8 @@ def _render_json(data):
def crawl_info(request):
_crawl_info = CrawlInfos.objects.order_by('-id').first()
return _render_json(_crawl_info)
data = json.loads(serialize('json',[_crawl_info]))[0]
return _render_json(data)
def platform_info(request):

View File

@ -8,6 +8,6 @@ urlpatterns = [
path('crawl', views.crawl, name='crawl'),
path('result', views.result, name='result'),
path('api/crawl_info.json', apis.crawl_info),
path('api/platform_info.json', apis.crawl_info),
path('api/platform_info.json', apis.platform_info),
]