web py 交互
This commit is contained in:
parent
5bc8f66473
commit
ea5ce567ef
@ -1,14 +1,26 @@
|
||||
from flask import Flask, render_template
|
||||
from pkg_resources import require
|
||||
from com.native.parser.parser_core import *
|
||||
|
||||
app = Flask(__name__)
|
||||
|
||||
|
||||
# 访问路径
|
||||
@app.route('/')
|
||||
def hello_world():
|
||||
stuInfo = {
|
||||
'sid': 111111,
|
||||
'name': 'jack',
|
||||
'native': 'China'
|
||||
}
|
||||
|
||||
|
||||
# 返回模板 index.html 模板引擎可以渲染number变量 传到前端
|
||||
return render_template('index.html', number=1111111)
|
||||
return render_template('index.html', info=stuInfo)
|
||||
|
||||
|
||||
@app.route('/search/<data>/', methods=['GET', 'POST'])
|
||||
def searchStu(data):
|
||||
return str(queryInfoBySid(data))
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
app.run()
|
||||
|
0
com/native/gui/controller/__init__.py
Normal file
0
com/native/gui/controller/__init__.py
Normal file
@ -3,8 +3,116 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
<!-- 引入样式 -->
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||
</head>
|
||||
<body>
|
||||
{{number}}
|
||||
|
||||
<div class="container">
|
||||
<div class="row align-items-start">
|
||||
<div class="col">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-start">
|
||||
<div class="col">
|
||||
<div class="input-group mb-3">
|
||||
<span class="input-group-text" id="inputGroup-sizing-default">sid | name | native</span>
|
||||
<input type="text" id="search_input" class="form-control" aria-label="Sizing example input"
|
||||
aria-describedby="inputGroup-sizing-default">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button type="button" id="search_btn" class="btn btn-primary">search</button>
|
||||
</div>
|
||||
<div class="col">
|
||||
<button type="button" class="btn btn-primary">add</button>
|
||||
<button type="button" class="btn btn-primary">remove</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-start">
|
||||
<div class="col">
|
||||
<div class="col">
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">#</th>
|
||||
<th scope="col">sid</th>
|
||||
<th scope="col">name</th>
|
||||
<th scope="col">native</th>
|
||||
<th scope="col">operation</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="col">
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row align-items-start">
|
||||
<div class="col">
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination">
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#" aria-label="Previous">
|
||||
<span aria-hidden="true">«</span>
|
||||
</a>
|
||||
</li>
|
||||
<li class="page-item"><a class="page-link" href="#">1</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#" aria-label="Next">
|
||||
<span aria-hidden="true">»</span>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
<!-- 引入组件库 -->
|
||||
<script src="http://libs.baidu.com/jquery/2.1.4/jquery.min.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script>
|
||||
|
||||
|
||||
<script>
|
||||
// function $(s) {
|
||||
// return document.getElementById(s)
|
||||
// }
|
||||
|
||||
$(function () {
|
||||
let tr = $('#col').append('<tr></tr>')
|
||||
tr.append('<th>1</th>')
|
||||
tr.append('<td>{{info.sid}}</td>')
|
||||
tr.append('<td>{{info.name}}</td>')
|
||||
tr.append('<td>{{info.native}}</td>')
|
||||
tr.append('<td></td>').append("<button type=\"button\" class=\"btn btn-outline-dark btn-sm\">update</button>\n  " +
|
||||
"<button type=\"button\" class=\"btn btn-outline-danger btn-sm\">remove</button>")
|
||||
})
|
||||
|
||||
</script>
|
||||
|
||||
<script>
|
||||
$("#search_btn").click(function () {
|
||||
let search = $("#search_input").val()
|
||||
ajax('/search',search)
|
||||
})
|
||||
|
||||
|
||||
function ajax(url,data) {
|
||||
$.ajax({
|
||||
url: url + '/' + data,
|
||||
type:'post',
|
||||
success:function (data){
|
||||
console.log(data)
|
||||
}
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
0
com/native/gui/templates/js/index.js
Normal file
0
com/native/gui/templates/js/index.js
Normal file
@ -4,15 +4,11 @@
|
||||
# version: 1.0
|
||||
###########################################################################################
|
||||
|
||||
from com.native.entity import entity
|
||||
from com.native.parser.parser_core import *
|
||||
from flask import Flask, render_template
|
||||
import com.native.gui
|
||||
|
||||
app = com.native.gui.app
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
# a = entity.Student("22100919", "某某某", "黑龙省")
|
||||
# inster(a)
|
||||
#
|
||||
# queryInfoBySid('22100915')
|
||||
# queryInfoBySid("某某")
|
||||
queryInfoByName("某某")
|
||||
|
||||
# delete('22100916')
|
||||
app.run()
|
||||
|
Loading…
x
Reference in New Issue
Block a user