update
This commit is contained in:
parent
b3626022bf
commit
86014afedb
|
|
@ -17,6 +17,8 @@ chardet==3.0.4
|
|||
SQLAlchemy==2.*
|
||||
Flask-SQLAlchemy==3.1.*
|
||||
Flask-Migrate==4.*
|
||||
#Flask-Security-Too==5.5.*; python_version >= '3.10'
|
||||
#Flask-Security-Too==5.4.*; python_version <= '3.9'
|
||||
pyOpenSSL==23.2.0
|
||||
cryptography>=40.0.2
|
||||
configparser==5.2.0
|
||||
|
|
|
|||
|
|
@ -13,32 +13,45 @@ import sys
|
|||
from flask import Flask
|
||||
from flask_socketio import SocketIO, emit, send
|
||||
from flask import Flask, abort, request, current_app, session, url_for
|
||||
from werkzeug.local import LocalProxy
|
||||
from flask import Blueprint, render_template
|
||||
from flask import render_template_string
|
||||
from flask_migrate import Migrate
|
||||
|
||||
from werkzeug.local import LocalProxy
|
||||
|
||||
from admin.model import db as sys_db
|
||||
|
||||
import core.mw as mw
|
||||
import setting
|
||||
|
||||
root_dir = mw.getRunDir()
|
||||
|
||||
socketio = SocketIO(manage_session=False, async_mode='threading',
|
||||
logger=False, engineio_logger=False, debug=False,
|
||||
ping_interval=25, ping_timeout=120)
|
||||
|
||||
|
||||
app = Flask(__name__, template_folder='templates/default')
|
||||
socketio.init_app(app, cors_allowed_origins="*")
|
||||
|
||||
|
||||
# 静态文件配置
|
||||
from whitenoise import WhiteNoise
|
||||
app.wsgi_app = WhiteNoise(app.wsgi_app, root="../web/static/", prefix="static/", max_age=604800)
|
||||
|
||||
# db的配置
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///'+root_dir+'/example.log' # 使用 SQLite 数据库
|
||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
|
||||
|
||||
# 初始化db
|
||||
sys_db.init_app(app)
|
||||
Migrate(app, sys_db)
|
||||
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///tmp/example.db' # 使用 SQLite 数据库
|
||||
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
|
||||
|
||||
with app.app_context():
|
||||
sys_db.create_all()
|
||||
|
||||
|
||||
# print(mw.getRunDir())
|
||||
# print(app.config['SQLALCHEMY_DATABASE_URI'])
|
||||
|
||||
|
||||
# 加载模块
|
||||
|
|
@ -71,6 +84,7 @@ def inject_global_variables():
|
|||
|
||||
|
||||
# from flasgger import Swagger
|
||||
# api = Api(app, version='1.0', title='API', description='API 文档')
|
||||
# Swagger(app)
|
||||
|
||||
# @app.route('/colors/<palette>/')
|
||||
|
|
@ -119,6 +133,11 @@ app.logger.info('Starting %s v%s...', setting.APP_NAME, setting.APP_VERSION)
|
|||
app.logger.info('########################################################')
|
||||
app.logger.debug("Python syspath: %s", sys.path)
|
||||
|
||||
|
||||
|
||||
# OK
|
||||
socketio.init_app(app, cors_allowed_origins="*")
|
||||
|
||||
# def create_app(app_name = None):
|
||||
#
|
||||
# if not app_name:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
# coding:utf-8
|
||||
|
||||
# ---------------------------------------------------------------------------------
|
||||
# MW-Linux面板
|
||||
# ---------------------------------------------------------------------------------
|
||||
# copyright (c) 2018-∞(https://github.com/midoks/mdserver-web) All rights reserved.
|
||||
# ---------------------------------------------------------------------------------
|
||||
# Author: midoks <midoks@163.com>
|
||||
# ---------------------------------------------------------------------------------
|
||||
|
||||
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
# from flask_security import UserMixin, RoleMixin
|
||||
import setting
|
||||
|
||||
SCHEMA_VERSION = 1
|
||||
|
||||
|
||||
db = SQLAlchemy(
|
||||
engine_options={
|
||||
'pool_size': setting.CONFIG_DATABASE_CONNECTION_POOL_SIZE,
|
||||
'max_overflow': setting.CONFIG_DATABASE_CONNECTION_MAX_OVERFLOW
|
||||
}
|
||||
)
|
||||
|
||||
class Version(db.Model):
|
||||
"""用于参考/升级的版本号"""
|
||||
__tablename__ = 'version'
|
||||
name = db.Column(db.String(32), primary_key=True)
|
||||
value = db.Column(db.Integer(), nullable=False)
|
||||
|
||||
class Role(db.Model):
|
||||
"""定义安全角色"""
|
||||
__tablename__ = 'role'
|
||||
id = db.Column(db.Integer(), primary_key=True)
|
||||
name = db.Column(db.String(128), unique=True, nullable=False)
|
||||
description = db.Column(db.String(256), nullable=False)
|
||||
|
|
@ -23,6 +23,13 @@ from version import APP_VERSION, APP_RELEASE, APP_REVISION, APP_SUFFIX
|
|||
|
||||
DEBUG = False
|
||||
|
||||
DEFAULT_SERVER = '127.0.0.1'
|
||||
# 配置数据库连接池大小。将其设置为0将删除任何限制
|
||||
CONFIG_DATABASE_CONNECTION_POOL_SIZE = 5
|
||||
# 允许溢出超过连接池大小的连接数
|
||||
CONFIG_DATABASE_CONNECTION_MAX_OVERFLOW = 100
|
||||
|
||||
|
||||
|
||||
DEFAULT_SERVER = '127.0.0.1'
|
||||
DEFAULT_SERVER_PORT = 7201
|
||||
|
||||
DEFAULT_SERVER_PORT = 7201
|
||||
Loading…
Reference in New Issue