diff --git a/app.py b/app.py index 0af25fad7..46b70788c 100644 --- a/app.py +++ b/app.py @@ -3,20 +3,16 @@ import sys import io import os -import time -from datetime import timedelta -sys.path.append("/class/core/") +sys.path.append("/class/core") reload(sys) sys.setdefaultencoding('utf8') import route -from flask import Flask +import config - -app = Flask(__name__) -app.debug = True +app = config.config().makeApp(__name__) DEFAULT_MODULES = ( @@ -35,13 +31,6 @@ DEFAULT_MODULES = ( ) -# print "time.time(): %f " % time.time() -app.config.version = "0.0.1" + str(time.time()) - -app.config['SECRET_KEY'] = os.urandom(24) -app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=7) - - def setting_modules(app, modules): for module, url_prefix in modules: app.register_blueprint(module, url_prefix=url_prefix) diff --git a/class/core/config.py b/class/core/config.py new file mode 100644 index 000000000..2e581175f --- /dev/null +++ b/class/core/config.py @@ -0,0 +1,33 @@ +# coding:utf-8 + +import sys +import io +import os +import time + +from flask import Flask +from datetime import timedelta + + +class config: + __version = '0.0.1' + __app = None + + def __init__(self): + pass + + def makeApp(self, name): + app = Flask(name) + app.debug = True + + app.config.version = self.__version + str(time.time()) + app.config['SECRET_KEY'] = os.urandom(24) + app.config['PERMANENT_SESSION_LIFETIME'] = timedelta(days=7) + __app = app + return app + + def getVersion(self): + return self.__version + + def getApp(self): + return self.__app diff --git a/class/core/public.py b/class/core/public.py index d84300405..554686ff4 100755 --- a/class/core/public.py +++ b/class/core/public.py @@ -682,7 +682,7 @@ def checkCert(certPath='ssl/certificate.pem'): # return result -def to_size(size): +def toSize(size): # 字节单位转换 d = ('b', 'KB', 'MB', 'GB', 'TB') s = d[0] @@ -694,6 +694,13 @@ def to_size(size): return str(size) + ' ' + b +def getMacAddress(): + # 获取mac + import uuid + mac = uuid.UUID(int=uuid.getnode()).hex[-12:] + return ":".join([mac[e:e + 2] for e in range(0, 11, 2)]) + + def get_string(t): if t != -1: max = 126 diff --git a/route/system.py b/route/system.py index 87bb56d63..bc8a4bfd9 100644 --- a/route/system.py +++ b/route/system.py @@ -25,7 +25,8 @@ def network(): @system.route("/update_server") def updateServer(): - data = system_api.system_api().updateServer('update') + data = system_api.system_api().updateServer('check') + print data return data diff --git a/static/js/index.js b/static/js/index.js index 1abc5cab0..f04e89e85 100755 --- a/static/js/index.js +++ b/static/js/index.js @@ -500,7 +500,7 @@ function checkUpdate() { function updateMsg(){ window.open("http://www.bt.cn/bbs/thread-1186-1-1.html"); - $.get('/ajax?action=UpdatePanel',function(rdata){ + $.get('/system/update_server',function(rdata){ layer.open({ type:1, title:lan.index.update_to+'['+rdata.version+']', @@ -515,7 +515,7 @@ function updateMsg(){ +'' +'' }); - }); + },'json'); }