企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
~~~ from flask import Blueprint # user = Blueprint('user', __name__, subdomain='api') # 子域名蓝图 user = Blueprint('user', __name__) @user.route('/get') def get_user(): return 'user' ~~~ ~~~ from flask import Flask def register_blueprints(app): ''' 注册蓝图 :param app: :return: ''' # from app.api.v1.client import client as client_blueprint # app.register_blueprint(client_blueprint, url_prefix='/v1/client') # 带版本的路由 from app.api.user import user as user_blueprint app.register_blueprint(user_blueprint, url_prefix='/user') def create_app(): # 注册app app = Flask(__name__) # app.config['SERVER_NAME'] = 'localhost:5001' # 配置子域名 api.localhost:5001/user/get # 加载配置文件 app.config.from_object('app.config.setting') app.config.from_object('app.config.secure') # 加载蓝图 register_blueprints(app) return app ~~~