From d54c43b45968105ba8ec5d1999ed86ea0898c965 Mon Sep 17 00:00:00 2001 From: pbr4nzfkh <18879212807@163.com> Date: Sat, 16 Mar 2024 22:17:03 +0800 Subject: [PATCH] restful-app --- 基本结构/042 restful/tf-35-app.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 基本结构/042 restful/tf-35-app.py diff --git a/基本结构/042 restful/tf-35-app.py b/基本结构/042 restful/tf-35-app.py new file mode 100644 index 0000000..b86da4f --- /dev/null +++ b/基本结构/042 restful/tf-35-app.py @@ -0,0 +1,18 @@ +from flask import Flask, request +from cppy.cp_util import * + +app = Flask(__name__) + +@app.route('/word_frequency', methods=['POST']) +def word_frequency(): + # 获取POST请求中的JSON数据 + data = request.get_json() + data = data['file'] + # 统计词频 + word_freq = get_frequencies(data) + word_freq = sort_dict(word_freq) + return word_freq + +if __name__ == '__main__': + app.run(debug=True) +