交互优化
This commit is contained in:
parent
2f40fe95a6
commit
63efc96eac
2
main.py
2
main.py
|
@ -273,6 +273,8 @@ def filter_group_mode1(parameter, group, hits):
|
|||
def predict():
|
||||
mode = request.args.get('mode')
|
||||
parameter = request.args.get('parameter')
|
||||
if len(trim_space(parameter)) == 0:
|
||||
return jsonify({'status': 1, 'message': '请输入参数', 'result': []})
|
||||
all_idiom, group = filter_logic(mode, parameter)
|
||||
result = get_max_group(all_idiom, group, 6)
|
||||
return jsonify({'status': 0, 'message': 'success', 'result': result})
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
|
||||
<!-- Bootstrap CSS -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
|
||||
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
</head>
|
||||
|
||||
|
@ -63,8 +64,12 @@
|
|||
<!-- Optional JavaScript -->
|
||||
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
|
||||
integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
|
||||
crossorigin="anonymous"></script>
|
||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
|
||||
integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
|
||||
crossorigin="anonymous"></script>
|
||||
<script>
|
||||
$(document).ready(function () {
|
||||
$('input[name=mode]').on('click', function (e) {
|
||||
|
@ -91,7 +96,10 @@
|
|||
$("#parameter").val('')
|
||||
})
|
||||
$('#submit').on('click', function () {
|
||||
$.get('/predict', { mode: $("input[name='mode']:checked").val(), parameter: $('#parameter').val() }, function (result) {
|
||||
$.ajax({
|
||||
url: '/predict',
|
||||
data: { mode: $("input[name='mode']:checked").val(), parameter: $('#parameter').val() },
|
||||
success: function (result,) {
|
||||
if (result && result.status === 0) {
|
||||
text = result.result.map(function (item) {
|
||||
return item.word + '\t' + item.pinyin
|
||||
|
@ -104,9 +112,13 @@
|
|||
}
|
||||
}
|
||||
else {
|
||||
$('#result').val(result)
|
||||
$('#result').val(result.message)
|
||||
}
|
||||
})
|
||||
},
|
||||
error: function(){
|
||||
$('#result').val('出错了,请检查参数')
|
||||
}
|
||||
});
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue