forked from pjialin/py12306
-
Notifications
You must be signed in to change notification settings - Fork 0
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
39 changed files
with
4,785 additions
and
23 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 |
---|---|---|
|
@@ -54,15 +54,22 @@ REDIS_HOST = 'localhost' # Redis host | |
REDIS_PORT = '6379' # Redis post | ||
REDIS_PASSWORD = '' # # Redis 密码 没有可以留空 | ||
|
||
|
||
# 邮箱配置 | ||
EMAIL_ENABLED = 0 # 是否开启邮件通知 | ||
EMAIL_SENDER = '[email protected]' # 邮件发送者 | ||
EMAIL_RECEIVER = '[email protected]' # 邮件接受者 # 可以多个 [[email protected], [email protected]] | ||
EMAIL_SERVER_HOST = 'localhost' # 邮件服务 host | ||
EMAIL_ENABLED = 0 # 是否开启邮件通知 | ||
EMAIL_SENDER = '[email protected]' # 邮件发送者 | ||
EMAIL_RECEIVER = '[email protected]' # 邮件接受者 # 可以多个 [[email protected], [email protected]] | ||
EMAIL_SERVER_HOST = 'localhost' # 邮件服务 host | ||
EMAIL_SERVER_USER = '' | ||
EMAIL_SERVER_PASSWORD = '' | ||
|
||
# Web 管理 | ||
WEB_ENABLE = 1 # 是否打开 Web 管理 | ||
WEB_USER = { # 登录信息 | ||
'username': 'admin', | ||
'password': 'password' | ||
} | ||
WEB_PORT = 8008 # 监听端口 | ||
|
||
# 查询任务 | ||
QUERY_JOBS = [ | ||
{ | ||
|
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
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
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
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
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,49 @@ | ||
import linecache | ||
|
||
from flask import Blueprint, request | ||
from flask.json import jsonify | ||
from flask_jwt_extended import (jwt_required) | ||
|
||
from py12306.config import Config | ||
from py12306.helpers.func import get_file_total_line_num | ||
from py12306.log.common_log import CommonLog | ||
from py12306.query.query import Query | ||
from py12306.user.user import User | ||
|
||
log = Blueprint('log', __name__) | ||
|
||
|
||
@log.route('/log/output', methods=['GET']) | ||
@jwt_required | ||
def log_output(): | ||
""" | ||
日志 | ||
:return: | ||
""" | ||
last_line = int(request.args.get('line', 0)) | ||
limit = int(request.args.get('limit', 10)) | ||
max_old = 200 # 取最新时 往后再取的数 | ||
file = Config().OUT_PUT_LOG_TO_FILE_PATH | ||
res = [] | ||
|
||
if last_line == -1: | ||
total_line = get_file_total_line_num(file) | ||
last_line = total_line - max_old if total_line > max_old else 0 | ||
ranges = range(max_old + limit) | ||
else: | ||
ranges = range(limit) | ||
|
||
if Config().OUT_PUT_LOG_TO_FILE_ENABLED: | ||
# with open(Config().OUT_PUT_LOG_TO_FILE_PATH, 'r', encoding='utf-8') as f: | ||
# res = f.readlines()[last_line:limit] | ||
linecache.updatecache(file) | ||
for i in ranges: | ||
tmp = linecache.getline(file, last_line + i) | ||
if tmp != '': res.append(tmp) | ||
last_line += len(res) | ||
else: | ||
res = CommonLog.MESSAGE_OUTPUT_TO_FILE_IS_UN_ENABLE | ||
return jsonify({ | ||
'last_line': last_line, | ||
'data': res | ||
}) |
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
15 changes: 15 additions & 0 deletions
15
py12306/web/static/css/app.dfb5ffed622907edd7c5f81709f2b782.css
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.