mirror of
https://github.com/midoks/mdserver-web.git
synced 2026-10-10 04:19:26 +08:00
update
This commit is contained in:
+25
-33
@@ -14,51 +14,43 @@ from flask import Flask
|
|||||||
from flask_socketio import SocketIO, emit, send
|
from flask_socketio import SocketIO, emit, send
|
||||||
from flask import Flask, abort, request, current_app, session, url_for
|
from flask import Flask, abort, request, current_app, session, url_for
|
||||||
from werkzeug.local import LocalProxy
|
from werkzeug.local import LocalProxy
|
||||||
|
from flask import Blueprint, render_template
|
||||||
|
|
||||||
|
import setting
|
||||||
|
|
||||||
socketio = SocketIO(manage_session=False, async_mode='threading',
|
socketio = SocketIO(manage_session=False, async_mode='threading',
|
||||||
logger=False, engineio_logger=False, debug=False,
|
logger=False, engineio_logger=False, debug=False,
|
||||||
ping_interval=25, ping_timeout=120)
|
ping_interval=25, ping_timeout=120)
|
||||||
|
|
||||||
class MwAdmin(Flask):
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
|
|
||||||
def find_submodules(self, basemodule):
|
app = Flask(__name__, template_folder='templates/default')
|
||||||
print(basemodule)
|
socketio.init_app(app, cors_allowed_origins="*")
|
||||||
|
|
||||||
@property
|
|
||||||
def submodules(self):
|
|
||||||
for blueprint in self.blueprints.values():
|
|
||||||
if isinstance(blueprint, PgAdminModule):
|
|
||||||
yield blueprint
|
|
||||||
|
|
||||||
|
|
||||||
def _find_blueprint():
|
# 加载模块
|
||||||
if request.blueprint:
|
from .submodules import get_submodules
|
||||||
return current_app.blueprints[request.blueprint]
|
for module in get_submodules():
|
||||||
|
app.logger.info('Registering blueprint module: %s' % module)
|
||||||
|
if app.blueprints.get(module.name) is None:
|
||||||
|
app.register_blueprint(module)
|
||||||
|
|
||||||
|
|
||||||
current_blueprint = LocalProxy(_find_blueprint)
|
# Log the startup
|
||||||
print("current_blueprint",current_blueprint)
|
app.logger.info('########################################################')
|
||||||
|
app.logger.info('Starting %s v%s...', setting.APP_NAME, setting.APP_VERSION)
|
||||||
|
app.logger.info('########################################################')
|
||||||
|
app.logger.debug("Python syspath: %s", sys.path)
|
||||||
|
|
||||||
def create_app(app_name = None):
|
|
||||||
import config
|
|
||||||
if not app_name:
|
|
||||||
app_name = config.APP_NAME
|
|
||||||
|
|
||||||
# Check if app is created for CLI operations or Web
|
# def create_app(app_name = None):
|
||||||
cli_mode = False
|
#
|
||||||
if app_name.endswith('-cli'):
|
# if not app_name:
|
||||||
cli_mode = True
|
# app_name = config.APP_NAME
|
||||||
|
|
||||||
app = MwAdmin(__name__, template_folder='templates/default')
|
# # Check if app is created for CLI operations or Web
|
||||||
socketio.init_app(app, cors_allowed_origins="*")
|
# cli_mode = False
|
||||||
|
# if app_name.endswith('-cli'):
|
||||||
|
# cli_mode = True
|
||||||
|
|
||||||
# Log the startup
|
|
||||||
app.logger.info('########################################################')
|
|
||||||
app.logger.info('Starting %s v%s...', config.APP_NAME, config.APP_VERSION)
|
|
||||||
app.logger.info('########################################################')
|
|
||||||
app.logger.debug("Python syspath: %s", sys.path)
|
|
||||||
|
|
||||||
return app
|
# return app
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
# coding:utf-8
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
# MW-Linux面板
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
# copyright (c) 2018-∞(https://github.com/midoks/mdserver-web) All rights reserved.
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
# Author: midoks <midoks@163.com>
|
||||||
|
# ---------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
from flask import Blueprint, render_template
|
||||||
|
|
||||||
|
blueprint = Blueprint('dashboard', __name__, url_prefix='/')
|
||||||
|
@blueprint.route('/')
|
||||||
|
def index():
|
||||||
|
return "dashboard"
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
|
||||||
|
from .dashboard import blueprint as DashboardModule
|
||||||
|
|
||||||
|
def get_submodules():
|
||||||
|
return [
|
||||||
|
DashboardModule,
|
||||||
|
]
|
||||||
+7
-7
@@ -22,18 +22,18 @@ if sys.path[0] != os.path.dirname(os.path.realpath(__file__)):
|
|||||||
|
|
||||||
# print(sys.path)
|
# print(sys.path)
|
||||||
|
|
||||||
import config
|
import setting
|
||||||
from admin import create_app, socketio
|
from admin import app, socketio
|
||||||
|
|
||||||
|
# print(setting.DEFAULT_SERVER,setting.DEFAULT_SERVER_PORT)
|
||||||
app = create_app()
|
# app = create_app()
|
||||||
def main():
|
def main():
|
||||||
socketio.run(
|
socketio.run(
|
||||||
app,
|
app,
|
||||||
debug=config.DEBUG,
|
debug=setting.DEBUG,
|
||||||
allow_unsafe_werkzeug=True,
|
allow_unsafe_werkzeug=True,
|
||||||
host=config.DEFAULT_SERVER,
|
host=setting.DEFAULT_SERVER,
|
||||||
port=config.EFFECTIVE_SERVER_PORT,
|
port=7201,
|
||||||
)
|
)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
+2
-1
@@ -2,6 +2,7 @@
|
|||||||
- 常用开发命令
|
- 常用开发命令
|
||||||
|
|
||||||
```
|
```
|
||||||
gunicorn -b :7200 -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 app:app
|
gunicorn -b :7201 -k geventwebsocket.gunicorn.workers.GeventWebSocketWorker -w 1 app:app
|
||||||
|
gunicorn -b :7201 -w 1 app:app
|
||||||
|
|
||||||
```
|
```
|
||||||
@@ -25,4 +25,4 @@ DEBUG = False
|
|||||||
|
|
||||||
DEFAULT_SERVER = '127.0.0.1'
|
DEFAULT_SERVER = '127.0.0.1'
|
||||||
|
|
||||||
DEFAULT_SERVER_PORT = 7200
|
DEFAULT_SERVER_PORT = 7201
|
||||||
Reference in New Issue
Block a user