From 7bb2a9ee03d9c2ed48ae69083e7342352861e7a1 Mon Sep 17 00:00:00 2001 From: Coaixy Date: Fri, 20 Dec 2024 14:18:45 +0800 Subject: [PATCH] delete unused function --- QuestionBank/QuestionBank.py | 51 ++++++++++++++++++------------------ main.py | 3 --- 2 files changed, 26 insertions(+), 28 deletions(-) diff --git a/QuestionBank/QuestionBank.py b/QuestionBank/QuestionBank.py index 3e5bf94..854891d 100644 --- a/QuestionBank/QuestionBank.py +++ b/QuestionBank/QuestionBank.py @@ -3,19 +3,20 @@ import difflib from json import JSONDecodeError -import uvicorn -from fastapi import FastAPI -from fastapi.middleware.cors import CORSMiddleware -app = FastAPI() +# import uvicorn +# from fastapi import FastAPI +# from fastapi.middleware.cors import CORSMiddleware -app.add_middleware( - CORSMiddleware, - allow_origins=['*'], # 允许的源 - allow_credentials=True, - allow_methods=["*"], # 允许的方法,如:GET, POST, OPTIONS 等 - allow_headers=["*"], # 允许的头 -) +# app = FastAPI() + +# app.add_middleware( +# CORSMiddleware, +# allow_origins=['*'], # 允许的源 +# allow_credentials=True, +# allow_methods=["*"], # 允许的方法,如:GET, POST, OPTIONS 等 +# allow_headers=["*"], # 允许的头 +# ) def get_all_json_files_content(directory): @@ -134,17 +135,17 @@ def generate_bank(directory='.'): bank_obj = {} -@app.get("/answer/{question}") -async def get_answer(question: str): - for i in bank_obj: - if question in i: - return {'question': i, 'msg': bank_obj[i]} - closest_match = difflib.get_close_matches(question, bank_obj.keys(), n=1, cutoff=0.6) - if closest_match: - return {'question': closest_match[0], 'msg': bank_obj[closest_match[0]]} - else: - return {'msg': '题目不存在'} - # return {'code': 200, 'msg': bank_obj.get(question, "题目不存在")} +# @app.get("/answer/{question}") +# async def get_answer(question: str): +# for i in bank_obj: +# if question in i: +# return {'question': i, 'msg': bank_obj[i]} +# closest_match = difflib.get_close_matches(question, bank_obj.keys(), n=1, cutoff=0.6) +# if closest_match: +# return {'question': closest_match[0], 'msg': bank_obj[closest_match[0]]} +# else: +# return {'msg': '题目不存在'} +# return {'code': 200, 'msg': bank_obj.get(question, "题目不存在")} def main(): @@ -152,8 +153,8 @@ def main(): with open("QuestionBank/result.json", 'r') as f: global bank_obj bank_obj = json.load(f) - uvicorn.run(app, host="127.0.0.1", port=8080) + # uvicorn.run(app, host="127.0.0.1", port=8080) -if __name__ == '__main__': - main() +# if __name__ == '__main__': +# main() diff --git a/main.py b/main.py index 324f6b8..d98fbf3 100644 --- a/main.py +++ b/main.py @@ -1,12 +1,9 @@ # @Author : Coaixy # @repo : https://www.github.com/coaixy/weiban-tool -import json import os import sys -import uuid import re -import requests from QuestionBank import QuestionBank