There is a feature: you need to refresh the background data periodically on the Web
Solution: Data via JSON to JS, set the timer for page local refresh processing
Code:
#django后台代码 @csrf_exempt @login_requireddef deploy_json (request, id): with open ("/data/shell/autodeploy.log", "R") as data: lines = len (List (enumerate (data))) if int (ID) <=lines: print Lines jsondata = json.dumps ([ {"Subject" : linecache.getline ("/data/shell/autodeploy.log", int (ID)), "Count" : lines }], ensure_ascii=false) print jsondata response = HttpResponse () response[' Content-Type '] = "Text/javascript" response.write (Jsondata) return response data.close () else: return httpresponse () data.close () @csrf_exempt @login_requireddef auto_ Deploy (Request): if request.method == ' POST ': subcmd. Jso_out ("Sh /data/shell/autodeploy.sh | tee /data/shell/autodeploy.log") return render_to_response ("deploy/auto_deploy.html") elif request.method == ' GET ': return render_to_response ("deploy/auto_deploy.html")
#html代码 {% extends "default/base.html" %}{% block title %} release system {% endblock %}{% block content %}<body class= "PageBg" > Effect:
650) this.width=650; "src=" Http://s4.51cto.com/wyfs02/M00/8A/05/wKioL1gkOS-QF-kaAAEpc018Ylk802.gif "title=" deploy "alt=" Wkiol1gkos-qf-kaaaepc018ylk802.gif "/>
This article is from the creator think blog, so be sure to keep this source http://strongit.blog.51cto.com/10020534/1871541
jquery action on JSON, dynamic refresh