From 8ebf71cc3f358c22f0849d3652e86f20e46da3ed Mon Sep 17 00:00:00 2001 From: zhiyang7 Date: Thu, 10 Feb 2022 15:00:59 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=89=8D=E7=AB=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.py | 10 ++++-- templates/index.html | 84 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 3 deletions(-) create mode 100644 templates/index.html diff --git a/main.py b/main.py index f13522d..e9eaa37 100644 --- a/main.py +++ b/main.py @@ -4,7 +4,7 @@ import pandas as pd import re import math import json -from flask import Flask, jsonify, request +from flask import Flask, jsonify, request, render_template from flask_cors import CORS from pypinyin import pinyin, lazy_pinyin, Style @@ -172,10 +172,10 @@ def filter_logic(mode, parameter): return None, None def filter_group_model2(parameter, group, hits, tones, tone_hits, word_hits): - group = filter_with_target_field(group, 'word', parameter, word_hits) + group = filter_with_target_field(group, 'pinyin_tone', tones, tone_hits) if len(group) <= 1: return group - group = filter_with_target_field(group, 'pinyin_tone', tones, tone_hits) + group = filter_with_target_field(group, 'word', parameter, word_hits) if len(group) <= 1: return group group['pinyin_0' ] = group.apply(lambda x: ','.join(list(lazy_pinyin(x['word'], style=Style.INITIALS, strict=False))), axis=1) @@ -267,6 +267,10 @@ def predict(): result = get_max_group(all_idiom, group, 3) return jsonify({'status': 0, 'message': 'success', 'result': result}) +@app.route('/', methods=['GET']) +def index(): + return render_template('index.html') + if __name__ == '__main__': current_work_dir = os.path.dirname(__file__) os.chdir(current_work_dir) diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..a5cff73 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,84 @@ + + + + Chinese Wordle Tools + + + + + +
+
+ +
+ + + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+
+ + + + + \ No newline at end of file