|
|
@ -67,7 +67,6 @@ def get_excel(question_id: str = Form(...), question_str: str = Form(...), db: P
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# http://10.10.21.20:8000/questions/get_docx_stream?question_id_get=af15d834-e7f5-46b4-a0f6-15f1f888f443
|
|
|
|
# http://10.10.21.20:8000/questions/get_docx_stream?question_id_get=af15d834-e7f5-46b4-a0f6-15f1f888f443
|
|
|
|
|
|
|
|
|
|
|
|
@app.api_route("/questions/get_docx_stream", methods=["POST", "GET"])
|
|
|
|
@app.api_route("/questions/get_docx_stream", methods=["POST", "GET"])
|
|
|
|
async def get_docx_stream(
|
|
|
|
async def get_docx_stream(
|
|
|
|
question_id: str = Form(None, description="问题ID(POST请求)"), # POST 请求参数
|
|
|
|
question_id: str = Form(None, description="问题ID(POST请求)"), # POST 请求参数
|
|
|
@ -155,11 +154,14 @@ async def get_docx_stream(
|
|
|
|
media_type="text/plain; charset=utf-8", # 明确指定字符编码为 UTF-8
|
|
|
|
media_type="text/plain; charset=utf-8", # 明确指定字符编码为 UTF-8
|
|
|
|
headers={
|
|
|
|
headers={
|
|
|
|
"Cache-Control": "no-cache", # 禁用缓存
|
|
|
|
"Cache-Control": "no-cache", # 禁用缓存
|
|
|
|
"Content-Type": "text/plain; charset=utf-8", # 设置内容类型和字符编码
|
|
|
|
"Content-Type": "text/event-stream; charset=utf-8", # 设置内容类型和字符编码
|
|
|
|
|
|
|
|
"Transfer-Encoding": "chunked",
|
|
|
|
|
|
|
|
"Connection": "keep-alive",
|
|
|
|
"X-Accel-Buffering": "no", # 禁用 Nginx 缓冲(如果使用 Nginx)
|
|
|
|
"X-Accel-Buffering": "no", # 禁用 Nginx 缓冲(如果使用 Nginx)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 返回生成的Word文件下载地址
|
|
|
|
# 返回生成的Word文件下载地址
|
|
|
|
# http://10.10.21.20:8000/questions/get_docx_file?question_id_get=af15d834-e7f5-46b4-a0f6-15f1f888f443
|
|
|
|
# http://10.10.21.20:8000/questions/get_docx_file?question_id_get=af15d834-e7f5-46b4-a0f6-15f1f888f443
|
|
|
|
@app.api_route("/questions/get_docx_file", methods=["POST", "GET"])
|
|
|
|
@app.api_route("/questions/get_docx_file", methods=["POST", "GET"])
|
|
|
@ -183,6 +185,21 @@ async def get_docx_file(
|
|
|
|
return {"success": True, "message": "Word文件生成成功", "download_url": f"{docx_file_name}"}
|
|
|
|
return {"success": True, "message": "Word文件生成成功", "download_url": f"{docx_file_name}"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 设置问题为系统推荐问题 ,0:取消,1:设置
|
|
|
|
|
|
|
|
@app.post("/questions/set_system_recommend")
|
|
|
|
|
|
|
|
def set_system_recommend(question_id: str = Form(...), flag: str = Form(...), db: PostgreSQLUtil = Depends(get_db)):
|
|
|
|
|
|
|
|
model_set_system_recommend(db, question_id, flag)
|
|
|
|
|
|
|
|
# 提示保存成功
|
|
|
|
|
|
|
|
return {"success": True, "message": "保存成功"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 设置问题为用户收藏问题 ,0:取消,1:设置
|
|
|
|
|
|
|
|
@app.post("/questions/set_user_collect")
|
|
|
|
|
|
|
|
def set_user_collect(question_id: str = Form(...), flag: str = Form(...), db: PostgreSQLUtil = Depends(get_db)):
|
|
|
|
|
|
|
|
model_set_user_collect(db, question_id, flag)
|
|
|
|
|
|
|
|
# 提示保存成功
|
|
|
|
|
|
|
|
return {"success": True, "message": "保存成功"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 确保直接运行脚本时启动 FastAPI 应用
|
|
|
|
# 确保直接运行脚本时启动 FastAPI 应用
|
|
|
|
if __name__ == "__main__":
|
|
|
|
if __name__ == "__main__":
|
|
|
|
uvicorn.run("app:app", host="0.0.0.0", port=8000, reload=True)
|
|
|
|
uvicorn.run("app:app", host="0.0.0.0", port=8000, reload=True)
|
|
|
|