-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
73 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ | |
""" | ||
|
||
from .bp_api_v1 import bp_api | ||
from .bp_backup import bp_backup | ||
from .bp_rss import bp_rss |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
""" | ||
Created by howie.hu at 2021-12-27. | ||
Description: liuli backup html 接口 | ||
Changelog: all notable changes to this file will be documented | ||
""" | ||
|
||
from flask import Blueprint, current_app | ||
|
||
from src.databases.mongodb_base import MongodbBase | ||
from src.databases.mongodb_tools import mongodb_find | ||
|
||
bp_backup = Blueprint("backup", __name__, url_prefix="/backup") | ||
|
||
|
||
@bp_backup.route( | ||
"/<doc_source>/<doc_source_name>/<doc_name>", | ||
methods=["GET"], | ||
strict_slashes=False, | ||
) | ||
def backup(doc_source, doc_source_name, doc_name): | ||
""" | ||
示例接口 | ||
:return: | ||
""" | ||
# 获取基本配置 | ||
mongodb_base: MongodbBase = current_app.config["mongodb_base"] | ||
logger = current_app.config["app_logger"] | ||
|
||
# 获取变量 | ||
file_path = f"{doc_source}/{doc_source_name}/{doc_name}" | ||
coll_rss_conn = mongodb_base.get_collection(coll_name="liuli_backup") | ||
filter_dict = { | ||
"doc_source": doc_source, | ||
"doc_source_name": doc_source_name, | ||
"doc_name": doc_name, | ||
} | ||
db_res = mongodb_find( | ||
coll_conn=coll_rss_conn, | ||
filter_dict=filter_dict, | ||
return_dict={"_id": 0}, | ||
limit=1, | ||
) | ||
db_satus, db_info = db_res["status"], db_res["info"] | ||
content = "" | ||
if db_satus: | ||
# 查询成功 | ||
if db_info: | ||
# 存在 | ||
content = db_info[0]["content"] | ||
else: | ||
# 不存在 rss | ||
msg = f"{file_path} 不存在,请先录入!" | ||
logger.error(msg) | ||
else: | ||
# 查询失败 | ||
msg = f"{file_path} 查询失败!" | ||
logger.error(msg) | ||
|
||
return ( | ||
content, | ||
200, | ||
{"Content-Type": "text/html; charset=utf-8"}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters