This commit is contained in:
parent
f1528326be
commit
4e57d509de
|
@ -18,3 +18,10 @@ def crawl_info(request):
|
|||
def platform_info(request):
|
||||
_info = get_platform_info()
|
||||
return _render_json(_info)
|
||||
|
||||
def news(request):
|
||||
news = News.objects.order_by('-id').all()[0:20]
|
||||
data = serialize('json', news)
|
||||
response = HttpResponse(json.dumps(data, ensure_ascii=False),
|
||||
content_type="application/json; charset=utf-8")
|
||||
return response
|
||||
|
|
|
@ -8,6 +8,12 @@ $(function(){
|
|||
|
||||
//更新抓取信息
|
||||
setInterval(function(){
|
||||
$.ajax('/myapp/api/news.json').done(function(datas){
|
||||
for(var i in datas){
|
||||
var data = datas[i];
|
||||
console.log(i);
|
||||
}
|
||||
});
|
||||
|
||||
$.ajax('/myapp/api/crawl_info.json').done(function(data){
|
||||
console.log(data);
|
||||
|
@ -26,10 +32,8 @@ $(function(){
|
|||
$('#mem_used').html(to_g(data.mem_used)+'G');
|
||||
$('#tasks_count').html(data.tasks);
|
||||
});
|
||||
|
||||
}, 1500);
|
||||
|
||||
|
||||
init();
|
||||
init2();
|
||||
$("#el-dialog").addClass("hide");
|
||||
|
|
|
@ -149,7 +149,7 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
{% for new in news %}
|
||||
<tr><td style="padding: 0px 11px;box-sizing: border-box;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">{{new.comment_id}}</td><td>{{new.content}}</td><td>{{new.comment_time}}</td></tr>
|
||||
<tr id="tr_news_{{forloop.counter0}}"><td style="padding: 0px 11px;box-sizing: border-box;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;" class="news_comment_id">{{new.comment_id}}</td><td class="news_content">{{new.content}}</td><td class="news_comment_time">{{new.comment_time}}</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
|
|
|
@ -9,5 +9,6 @@ urlpatterns = [
|
|||
path('result', views.result, name='result'),
|
||||
path('api/crawl_info.json', apis.crawl_info),
|
||||
path('api/platform_info.json', apis.platform_info),
|
||||
path('api/news.json', apis.news),
|
||||
|
||||
]
|
||||
|
|
Loading…
Reference in New Issue