update
This commit is contained in:
parent
e3ccf0db0d
commit
61f505d439
@ -12,7 +12,7 @@
|
|||||||
- 添加更多RSS订阅源(持续进行中)
|
- 添加更多RSS订阅源(持续进行中)
|
||||||
- 添加更多推送方式,如邮件、微信等
|
- 添加更多推送方式,如邮件、微信等
|
||||||
- 添加谷歌搜索等更多相关检测源,后续将支持谷歌语法
|
- 添加谷歌搜索等更多相关检测源,后续将支持谷歌语法
|
||||||
- 添加性能限制模块
|
- 将搜狗-微信和GitHub同步上网站推送
|
||||||
|
|
||||||
### 下一步计划(已完成)
|
### 下一步计划(已完成)
|
||||||
- 将所有打印信息转为logging info并存档(已完成)<br>
|
- 将所有打印信息转为logging info并存档(已完成)<br>
|
||||||
@ -24,6 +24,7 @@
|
|||||||
- 更换筛选模块,由时段筛选改为历史记录筛选以确保不会有资讯漏报(筛选条件增加了时间筛选和是否已发送筛选)
|
- 更换筛选模块,由时段筛选改为历史记录筛选以确保不会有资讯漏报(筛选条件增加了时间筛选和是否已发送筛选)
|
||||||
- 添加GitHub等监测源(重构参考项目逻辑并上线)
|
- 添加GitHub等监测源(重构参考项目逻辑并上线)
|
||||||
- 添加百度监测源
|
- 添加百度监测源
|
||||||
|
- 添加性能限制模块(限制每次读取数量)
|
||||||
|
|
||||||
### 下一步计划(已作废)
|
### 下一步计划(已作废)
|
||||||
- 添加Mysql作为数据库存储(现有sqlite已满足使用)
|
- 添加Mysql作为数据库存储(现有sqlite已满足使用)
|
||||||
@ -43,4 +44,5 @@
|
|||||||
- 2025年01月05日晚:修复了doonsec相关配置的bug,程序现已可正常运行
|
- 2025年01月05日晚:修复了doonsec相关配置的bug,程序现已可正常运行
|
||||||
- 2025年01月06日:更新了配置信息自动获取的逻辑,添加关键词等现可在运行时添加,重要配置信息(config.yaml)仍需暂停重新运行
|
- 2025年01月06日:更新了配置信息自动获取的逻辑,添加关键词等现可在运行时添加,重要配置信息(config.yaml)仍需暂停重新运行
|
||||||
- 2025年01月10日上午:修复了github推送的问题(时区,消息配置错误等)
|
- 2025年01月10日上午:修复了github推送的问题(时区,消息配置错误等)
|
||||||
- 2025年01月10日下午:上线了百度搜索内容监测
|
- 2025年01月10日下午:上线了百度搜索内容监测
|
||||||
|
- 2025年01月14日晚:添加了网站读取文件逻辑仅读取限制数量的文件,避免文件过大导致程序崩溃或是阅读困难
|
@ -1 +0,0 @@
|
|||||||
|
|
24
web/app.py
24
web/app.py
@ -1,4 +1,5 @@
|
|||||||
from flask import Flask, jsonify, render_template
|
from flask import Flask, jsonify, render_template
|
||||||
|
from collections import deque
|
||||||
import os
|
import os
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
@ -29,6 +30,17 @@ def index():
|
|||||||
logging.info("访问主页")
|
logging.info("访问主页")
|
||||||
return render_template('index.html')
|
return render_template('index.html')
|
||||||
|
|
||||||
|
def get_records(content, num_records=20, delimiter='-'*40):
|
||||||
|
records = content.split(delimiter)
|
||||||
|
# 去除空字符串,去除之后MD格式会混乱
|
||||||
|
# records = [record.strip() for record in records if record.strip()]
|
||||||
|
selected_records = records[:num_records]
|
||||||
|
return delimiter.join(selected_records)
|
||||||
|
|
||||||
|
def read_last_lines(file_path, num_lines=100):
|
||||||
|
with open(file_path, 'r', encoding='utf-8') as file:
|
||||||
|
return deque(file, maxlen=num_lines)
|
||||||
|
|
||||||
@app.route('/get-sec-news')
|
@app.route('/get-sec-news')
|
||||||
def get_sec_news():
|
def get_sec_news():
|
||||||
logging.info(f"尝试打开安全新闻历史推送文件: {SEC_NEWS_PATH}")
|
logging.info(f"尝试打开安全新闻历史推送文件: {SEC_NEWS_PATH}")
|
||||||
@ -36,6 +48,7 @@ def get_sec_news():
|
|||||||
with open(SEC_NEWS_PATH, 'r', encoding='utf-8') as file:
|
with open(SEC_NEWS_PATH, 'r', encoding='utf-8') as file:
|
||||||
content = file.read()
|
content = file.read()
|
||||||
content = replace_content(content)
|
content = replace_content(content)
|
||||||
|
content = get_records(content)
|
||||||
return jsonify({'content': content}), 200
|
return jsonify({'content': content}), 200
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
logging.error(f"文件缺失: {SEC_NEWS_PATH}")
|
logging.error(f"文件缺失: {SEC_NEWS_PATH}")
|
||||||
@ -51,6 +64,7 @@ def get_tech_passage():
|
|||||||
with open(TECH_PASSAGE_PATH, 'r', encoding='utf-8') as file:
|
with open(TECH_PASSAGE_PATH, 'r', encoding='utf-8') as file:
|
||||||
content = file.read()
|
content = file.read()
|
||||||
content = replace_content(content)
|
content = replace_content(content)
|
||||||
|
content = get_records(content)
|
||||||
return jsonify({'content': content}), 200
|
return jsonify({'content': content}), 200
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
logging.error(f"文件缺失: {TECH_PASSAGE_PATH}")
|
logging.error(f"文件缺失: {TECH_PASSAGE_PATH}")
|
||||||
@ -63,16 +77,16 @@ def get_tech_passage():
|
|||||||
def get_log():
|
def get_log():
|
||||||
logging.info(f"尝试打开核心日志文件: {CORE_LOG_PATH}")
|
logging.info(f"尝试打开核心日志文件: {CORE_LOG_PATH}")
|
||||||
# 读取日志文件内容
|
# 读取日志文件内容
|
||||||
with open(CORE_LOG_PATH, 'r', encoding='utf-8') as file:
|
log_content = read_last_lines(CORE_LOG_PATH)
|
||||||
log_content = file.read()
|
log_content = '\n'.join(log_content)
|
||||||
# 将日志内容传递给模板
|
# 将日志内容传递给模板
|
||||||
return render_template('log.html', log_content=log_content)
|
return render_template('log.html', log_content=log_content)
|
||||||
|
|
||||||
@app.route('/weblog')
|
@app.route('/weblog')
|
||||||
def get_weblog():
|
def get_weblog():
|
||||||
logging.info(f"尝试打开Web应用日志文件: {WEB_LOG_PATH}")
|
logging.info(f"尝试打开Web应用日志文件: {WEB_LOG_PATH}")
|
||||||
with open(WEB_LOG_PATH, 'r') as file:
|
log_content = read_last_lines(WEB_LOG_PATH)
|
||||||
log_content = file.read()
|
log_content = '\n'.join(log_content)
|
||||||
log_content = replace_content(log_content)
|
log_content = replace_content(log_content)
|
||||||
return render_template('log.html', log_content=log_content)
|
return render_template('log.html', log_content=log_content)
|
||||||
|
|
||||||
@ -80,4 +94,4 @@ def run_server():
|
|||||||
app.run(host='0.0.0.0', port=5000)
|
app.run(host='0.0.0.0', port=5000)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(debug=False) # 在生产环境中应设置为 False
|
app.run(debug=True) # 在生产环境中应设置为 False
|
@ -39,6 +39,13 @@
|
|||||||
#back-to-top:hover {
|
#back-to-top:hover {
|
||||||
background-color: #777;
|
background-color: #777;
|
||||||
}
|
}
|
||||||
|
#markdown-content a {
|
||||||
|
color: blue;
|
||||||
|
text-decoration: none; /* 可选:去掉下划线 */
|
||||||
|
}
|
||||||
|
#markdown-content a:hover {
|
||||||
|
text-decoration: underline; /* 可选:鼠标悬停时显示下划线 */
|
||||||
|
}
|
||||||
|
|
||||||
/* 移动端样式调整 */
|
/* 移动端样式调整 */
|
||||||
@media only screen and (max-width: 600px) {
|
@media only screen and (max-width: 600px) {
|
||||||
@ -55,13 +62,21 @@
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
padding: 8px;
|
padding: 8px;
|
||||||
}
|
}
|
||||||
|
#markdown-content a {
|
||||||
|
color: blue;
|
||||||
|
text-decoration: none; /* 可选:去掉下划线 */
|
||||||
|
}
|
||||||
|
#markdown-content a:hover {
|
||||||
|
text-decoration: underline; /* 可选:鼠标悬停时显示下划线 */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="layui-container">
|
<div class="layui-container">
|
||||||
<center><h1 class="layui-title" id="page-title">历史推送读取</h1><br>
|
<center><h1 class="layui-title" id="page-title">历史推送读取</h1><br>
|
||||||
<button id="toggle-fetch-btn" class="layui-btn">切换读取源</button><br></center>
|
<button id="toggle-fetch-btn" class="layui-btn">切换读取源</button><br>
|
||||||
|
<h4>为保证网页运作性能,默认仅读取前20条记录,若您有需求可自行更改app.py</h4></center>
|
||||||
<div id="markdown-content" class="layui-card-body"></div>
|
<div id="markdown-content" class="layui-card-body"></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<div class="layui-container">
|
<div class="layui-container">
|
||||||
<h1 class="layui-title">程序运行日志</h1>
|
<h1 class="layui-title">程序运行日志</h1>
|
||||||
|
<h4>为保证网页运作性能,默认仅读取后100条记录,若您有需求可自行更改app.py</h4><br>
|
||||||
<pre>{{ log_content }}</pre>
|
<pre>{{ log_content }}</pre>
|
||||||
<div id="markdown-content" class="layui-card-body"></div>
|
<div id="markdown-content" class="layui-card-body"></div>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user