feat(all): init
This commit is contained in:
17
addons/__init__.py
Normal file
17
addons/__init__.py
Normal file
@@ -0,0 +1,17 @@
|
||||
import os
|
||||
from flask import Flask
|
||||
from importlib import import_module
|
||||
|
||||
"""
|
||||
自动载入所有插件,并注入应用上下文
|
||||
通过插件内的 manifest 信息识别是否为内置插件,第三方插件需要自行上传到此目录下
|
||||
manifest 需注释为第三方,否则会在比对数据库后直接过滤
|
||||
"""
|
||||
def autoload_addon_and_inject_context(app: Flask):
|
||||
addons_dir = os.path.dirname(__file__)
|
||||
for item in os.listdir(addons_dir):
|
||||
item_path = os.path.join(addons_dir, item)
|
||||
if os.path.isdir(item_path) and os.path.exists(os.path.join(item_path, '__init__.py')):
|
||||
addon_module = import_module(f'addons.{item}')
|
||||
if hasattr(addon_module, 'register_addon'):
|
||||
addon_module.register_addon(app)
|
||||
16
addons/account/__init__.py
Normal file
16
addons/account/__init__.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from flask import Flask
|
||||
|
||||
manifest = {
|
||||
"name": "Account Addon",
|
||||
"version": "1.0.0",
|
||||
"description": "An addon to manage user accounts.",
|
||||
"author": "Mike",
|
||||
"license": "",
|
||||
"url": "",
|
||||
"addon": "account"
|
||||
}
|
||||
|
||||
def register_addon(app: Flask):
|
||||
from .api import bp
|
||||
app.register_blueprint(bp, url_prefix='/account')
|
||||
pass
|
||||
11
addons/account/api.py
Normal file
11
addons/account/api.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from flask import Blueprint
|
||||
|
||||
bp = Blueprint('account', __name__)
|
||||
|
||||
@bp.route('/')
|
||||
def account_home():
|
||||
return "Welcome to the Account Addon!"
|
||||
|
||||
@bp.route('/profile')
|
||||
def profile():
|
||||
return "This is the user profile page."
|
||||
0
addons/account/model.py
Normal file
0
addons/account/model.py
Normal file
Reference in New Issue
Block a user