Want to see someone click on the news link on my page, I wrote this to see, the result n days is my own point of the front-end main code (Django template)
<!-- HTML5 Latest Consulting--> <div class= "Djangonew" style= "overflow:auto;float:right;aborder:1px solid red;height:10%;width:49%; " >
Back-end Code (Django)
#访问状态 @login_required (login_url= "/") Def visit (Request): r10=redis (host= ' localhost '), Port=6379,db=10,password= ' * * ') r12=redis (host= ' localhost ', port=6379,db=12,password= ' * * ') ) #mongo click_url today_sec = time.mktime ( Time.strptime (Time.strftime ("%y%m%d"), "%y%m%d")) curl_data = db.curl.find ({' Date ': {' $gte ': today_sec}},{' _id ': 0}] curl_data = list (curl_data) if len (Curl_data): for i in curl_data: i[' Date '] = Time.strftime ("%y%m%d %t", Time.localtime (i[' Date ')) #在线 Online_ipall=[] for i in r10.keys (' ip* '): online_ipall. Append ((I,r10.get (i)) #今天 today_ipallwx=[] for i in r12.keys (' ip* '): today_ Ipallwx.append ((I,r12.lrange (i,start=0,end=-1))) today_ipall=sorted (today_ipallwx,key= lambda x:x[1][1],reverse=true) return render_to_response (' Plug/visit_ State.html ', {"Curl_data": Curl_data, "Online_ipall": Online_ipall, "Today_ipall": Today_ipall},requestcontext ( Request)) #点击超链接统计def click_url (Request): if request.method == ' POST ': url = request. Post.get (' url ') ip = request. Post.get (' IP ') db.curl.insert ({' IP ':ip, ' url ':url, ' Date ': Time.time ()}) return httpresponse ("OK")
View:
650) this.width=650; "src=" http://www.feifeiwd.com/static/img/blog/urlvisit.jpg "height=" 407 "width=" 836 "alt=" Urlvisit.jpg "/>
This article is from the "Peninsula Learning Notes" blog, so be sure to keep this source http://bandao.blog.51cto.com/4522715/1692318
Site hyperlink Click to save to MongoDB