From 2f6f56e11a7539eb9c974c280a5ec57d448b2a41 Mon Sep 17 00:00:00 2001 From: root <544401058@qq.com> Date: Thu, 11 Nov 2021 19:06:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=80=E4=BA=9Bredis?= =?UTF-8?q?=E7=9A=84=E5=B0=8F=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 2 +- detect_trustie.py | 5 ++++- templates/input.html | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app.py b/app.py index 662049a..eb8f1a8 100644 --- a/app.py +++ b/app.py @@ -120,4 +120,4 @@ def output(): if __name__ == '__main__': - app.run(host="localhost", debug=True) \ No newline at end of file + app.run(host="0.0.0.0", debug=True) \ No newline at end of file diff --git a/detect_trustie.py b/detect_trustie.py index 2d19027..5012747 100644 --- a/detect_trustie.py +++ b/detect_trustie.py @@ -1,3 +1,4 @@ +from re import T import requests import json import jieba @@ -10,7 +11,7 @@ import math import redis token = "" -r = redis.StrictRedis(host="localhost", port=6379, db=0) +r = redis.StrictRedis(host="localhost", port=6379, db=0, decode_responses=True) def crawl_api(url): header = {"Authorization": "token %s" % token} @@ -73,6 +74,7 @@ def crawl_all_pr(url): def detect_text_file_dup(all_pr_info, project_key, pr_num): + print(r.get(project_key + "_" + str(pr_num))) current_pr_value = json.loads(r.get(project_key + "_" + str(pr_num))) current_word = jieba.lcut(current_pr_value["title"] + " " + current_pr_value['description']) current_word = [x.strip() for x in current_word if x.strip() != ''] @@ -165,6 +167,7 @@ def main(repo, pr_num, url_head): file = extract_filename(file_info) # 解析title value = {"title": title, "description": description, "file": file} + r.set(project_pr_key, json.dumps(value)) # 将需要缓存的数据写入redis数据库 else: pass # 跳过,下一步直接获取缓存数据 diff --git a/templates/input.html b/templates/input.html index adf5123..fd4e715 100644 --- a/templates/input.html +++ b/templates/input.html @@ -13,7 +13,7 @@
+ action="http://106.75.189.31:5000/result" method="POST" name="input_url">
PR URL