mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 04:19:26 +08:00
update
This commit is contained in:
@@ -14,29 +14,6 @@ import config
|
||||
|
||||
app = config.config().makeApp(__name__)
|
||||
|
||||
|
||||
DEFAULT_MODULES = (
|
||||
(route.dashboard, "/"),
|
||||
(route.site, "/site"),
|
||||
(route.files, "/files"),
|
||||
(route.soft, "/soft"),
|
||||
(route.config, "/config"),
|
||||
(route.plugins, "/plugins"),
|
||||
(route.task, "/task"),
|
||||
(route.system, "/system"),
|
||||
(route.database, "/database"),
|
||||
(route.crontab, "/crontab"),
|
||||
(route.firewall, "/firewall"),
|
||||
(route.control, "/control"),
|
||||
)
|
||||
|
||||
|
||||
def setting_modules(app, modules):
|
||||
for module, url_prefix in modules:
|
||||
app.register_blueprint(module, url_prefix=url_prefix)
|
||||
|
||||
setting_modules(app, DEFAULT_MODULES)
|
||||
|
||||
try:
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
|
||||
+37
-3
@@ -13,17 +13,30 @@ sys.path.append(os.getcwd() + "/class/core")
|
||||
# sys.setdefaultencoding('utf-8')
|
||||
import db
|
||||
import public
|
||||
import route
|
||||
|
||||
|
||||
class MiddleWare:
|
||||
|
||||
def __init__(self, wsgi_app):
|
||||
self.wsgi_app = wsgi_app
|
||||
|
||||
def __call__(self, *args, **kwargs):
|
||||
# print args
|
||||
return self.wsgi_app(*args, **kwargs)
|
||||
|
||||
|
||||
class config:
|
||||
__version = '0.0.1'
|
||||
__app = None
|
||||
__modules = None
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def makeApp(self, name):
|
||||
app = Flask(name)
|
||||
self.__app = app
|
||||
|
||||
app.config.version = self.__version
|
||||
app.config['SECRET_KEY'] = os.urandom(24)
|
||||
@@ -32,11 +45,10 @@ class config:
|
||||
# app.debug = True
|
||||
# app.config.version = self.__version + str(time.time())
|
||||
|
||||
__app = app
|
||||
|
||||
self.initDB()
|
||||
|
||||
self.initInitD()
|
||||
self.initRoute()
|
||||
app.wsgi_app = MiddleWare(app.wsgi_app)
|
||||
return app
|
||||
|
||||
def initDB(self):
|
||||
@@ -75,3 +87,25 @@ class config:
|
||||
|
||||
def getApp(self):
|
||||
return self.__app
|
||||
|
||||
def initRoute(self):
|
||||
DEFAULT_MODULES = (
|
||||
(route.dashboard, "/"),
|
||||
(route.site, "/site"),
|
||||
(route.files, "/files"),
|
||||
(route.soft, "/soft"),
|
||||
(route.config, "/config"),
|
||||
(route.plugins, "/plugins"),
|
||||
(route.task, "/task"),
|
||||
(route.system, "/system"),
|
||||
(route.database, "/database"),
|
||||
(route.crontab, "/crontab"),
|
||||
(route.firewall, "/firewall"),
|
||||
(route.control, "/control"),
|
||||
)
|
||||
self.modules = DEFAULT_MODULES
|
||||
self.settingModules(self.__app, DEFAULT_MODULES)
|
||||
|
||||
def settingModules(self, app, modules):
|
||||
for module, url_prefix in modules:
|
||||
app.register_blueprint(module, url_prefix=url_prefix)
|
||||
|
||||
@@ -34,6 +34,7 @@ def login_required(func):
|
||||
@dashboard.route("/test")
|
||||
@login_required
|
||||
def test():
|
||||
print session
|
||||
os = public.getOs()
|
||||
print os
|
||||
|
||||
@@ -97,4 +98,6 @@ def doLogin():
|
||||
"< a style='color: red'>密码错误</a>,帐号:{1},密码:{2},登录IP:{3}", (('****', '******', request.remote_addr))))
|
||||
return public.returnJson(False, public.getInfo("用户名或密码错误,您还可以尝试[{1}]次!", ('1')))
|
||||
|
||||
session['login'] = True
|
||||
session['username'] = userInfo['username']
|
||||
return public.returnJson(True, '登录成功,正在跳转...')
|
||||
|
||||
Reference in New Issue
Block a user