提交 66274a13 编写于 作者: H hjdhnx

修复首页日志打印问题

上级 fc56f5dc
......@@ -29,7 +29,7 @@ app.config.from_object(config) # 单独的配置文件里写了,这里就不
db = SQLAlchemy(app)
rule_list = getRules()
print(rule_list)
# print(rule_list)
from models import *
......@@ -129,21 +129,6 @@ def getRules(path='cache'):
rules = {'list': rule_list, 'count': len(rule_list)}
return rules
def getHost(mode=0,port=None):
port = port or request.environ.get('SERVER_PORT')
hostname = socket.gethostname()
ip = socket.gethostbyname(hostname)
# ip = request.remote_addr
# print(ip)
# mode 为0是本地,1是局域网 2是线上
if mode == 0:
host = f'localhost:{port}'
elif mode == 1:
host = f'{ip}:{port}'
else:
host = 'cms.nokia.press'
return host
@app.route('/favicon.ico') # 设置icon
def favicon():
......@@ -227,9 +212,7 @@ def database():
if __name__ == '__main__':
print(f'http://{getHost(1, 5705)}/index')
# app.run(host="0.0.0.0", port=5705)
# app.run(debug=True, host='0.0.0.0', port=5705)
print('http://localhost:5705/index')
WSGIServer(('0.0.0.0', 5705), app).serve_forever()
# WSGIServer(('0.0.0.0', 5705), app,log=None).serve_forever()
\ No newline at end of file
......@@ -13,10 +13,15 @@ from utils.htmlParser import jsoup
from urllib.parse import urljoin
from concurrent.futures import ThreadPoolExecutor # 引入线程池
import logging
from js.rules import getRules
_logger = logging.getLogger(__name__)
print(_logger)
rule_list = getRules()
print(rule_list)
_logger.info('cms类装载完毕')
print(f'http://{getHost(1, 5705)}/index\nhttp://localhost:5705/index')
class CMS:
def __init__(self,rule,db=None,RuleClass=None):
......
......@@ -4,6 +4,9 @@
# Author: DaShenHan&道长-----先苦后甜,任凭晚风拂柳颜------
# Date : 2022/8/25
import socket
from flask import request
MOBILE_UA = 'Mozilla/5.0 (Linux; Android 11; M2007J3SC Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045714 Mobile Safari/537.36'
PC_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36'
UA = 'Mozilla/5.0'
......@@ -12,3 +15,18 @@ headers = {
'Referer': 'https://www.baidu.com',
'user-agent': UA,
}
def getHost(mode=0,port=None):
port = port or request.environ.get('SERVER_PORT')
hostname = socket.gethostname()
ip = socket.gethostbyname(hostname)
# ip = request.remote_addr
# print(ip)
# mode 为0是本地,1是局域网 2是线上
if mode == 0:
host = f'localhost:{port}'
elif mode == 1:
host = f'{ip}:{port}'
else:
host = 'cms.nokia.press'
return host
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册