???????????
????Django?????????????????????????????????????????????????views????д????????3??txt???????????Щ??????????????????????Bootstrap?????????????????????????????檔
def index(request):
rightside = []
result = []
rst_data = []
leftside = []
passed = 0
fail = 0
noresult = 0
with open(os.getcwd() + '/PortTest/leftside.txt') as ls:
for x in ls.readlines():
lf_data = {
'code': x.strip().split('-')[0]??
'title': x.strip().split('-')[1]
}
leftside.append(lf_data)
with open(os.getcwd() + '/PortTest/rightside.txt') as rs:
for x in rs.readlines():
row = x.strip().split('|')
rs_data = {
"fssj": row[0]??
"csbt": row[1]??
"fsfs": row[2]??
"alms": row[3]??
"fsdz": row[4]??
"fscs": row[5]??
'testid': row[6]
}
rightside.append(rs_data)
with open(os.getcwd() + '/PortTest/result.txt') as rst:
for x in rst.readlines():
row = x.strip().split('|')
if row[len(row)-1] == 'fail':
fail += 1
elif row[len(row)-1] == 'pass':
passed += 1
elif row[len(row)-1] == 'no except result':
noresult += 1
rs_data = []
for y in row:
rs_data.append(y)
result.append(rs_data)
for a?? b in zip(rightside?? result):
data = {
"sendData": a??
"dealData": b??
"result": b[len(b)-1]
}
rst_data.append(data)
return render(request?? 'PortTest/index.html'?? {"leftside": leftside??
"rst_data": rst_data??
"pass": passed??
"fail": fail??
"noresult": noresult})
??????????????Щ????????????????????????????????????????????????洢????????????????????洢??views??????????????????
?????????????£?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="http://jb51.net/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<script src="http://fuck.thinksaas.cn/get/http://jb51.net/jquery/2.0.0/jquery.min.js"></script>
<script src="http://fuck.thinksaas.cn/get/http://jb51.net/bootstrap/3.0.3/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="page-header">
<h1>?????????
<small>Design By Sven</small>
</h1>
</div>
</div>
<div class="row">
<div class="col-md-4">
<h3>??????? <span class="label label-success">{{ pass }}</span></h3>
</div>
<div class="col-md-4">
<h3>??????? <span class="label label-danger">{{ fail }}</span></h3>
</div>
<div class="col-md-4">
<h3>???? <span class="label label-warning">{{ noresult }}</span></h3>
</div>
</div>
<p></p>
<div class="row">
<div class="col-md-3">
<ul class="list-group">
{% for ls in leftside %}
<li class="list-group-item"><a href="#{{ ls.code }}">{{ ls.code }} - {{ ls.title }}</a></li>
{% endfor %}
</ul>
</div>
<div class="col-md-9">
{{ x.result }}
{% for x in rst_data %}
<div class="panel-group" id="accordion">
{% if x.result == 'pass' %}
<div class="panel panel-success">
{% elif x.result == 'fail' %}
<div class="panel panel-danger">
{% elif x.result == 'no except result' %}
<div class="panel panel-warning">
{% endif %}
<div class="panel-heading">
<h4 class="panel-title">
<a data-toggle="collapse" href="#{{ x.sendData.testid }}">
{{ x.sendData.testid }} - {{ x.sendData.csbt }}
</a>
</h4>
</div>
<div id="{{ x.sendData.testid }}" class="panel-collapse collapse">
<div class="panel-body">
<b>{{ x.sendData.fssj }}</b><br>
{{ x.sendData.csbt }}<br>
{{ x.sendData.fsfs }}<br>
{{ x.sendData.alms }}<br>
{{ x.sendData.fsdz }}<br>
{{ x.sendData.fscs }}
<hr>
{% for v in x.dealData %}
{{ v }}<br>
{% endfor %}
</div>
</div>
</div>
</div>
<p></p>
{% endfor %}
</div>
</div>
</div>
<script>
$(function () {
$(window).scroll(function () {
if ($(this).scrollTop() != 0) {
$("#toTop").fadeIn();
} else {
$("#toTop").fadeOut();
}
});
$("body").append("<div id="toTop" style="border:1px solid #444;background:#333;color:#fff;text-align:center;padding:10px 13px 7px 13px;position:fixed;bottom:10px;right:10px;cursor:pointer;display:none;font-family:verdana;font-size:22px;">^</div>");
$("#toTop").click(function () {
$("body??html").animate({scrollTop: 0}?? 800);
});
});
</script>
</body>
</html>
???????????Ч???

??????
??????Pythonд????????????????????????????????????????е????????????????????????????????????????????????????