- 移除 magnet_bp 蓝图及其路由配置 - 删除 app/__init__.py 中的 magnet_bp 导入和注册 - 移除 app/services/magnet_service.py 服务文件 - 从 requirements.txt 中删除 libtorrent 依赖 - 保留 Flask-CORS 但移除其他无关依赖项位置调整
33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
from flask import Flask
|
|
from flask_cors import CORS
|
|
from .extensions import db, migrate
|
|
from .config import DevelopmentConfig, ProductionConfig, TestingConfig
|
|
from .blueprints import torrent_bp, book_bp, music_bp, file_bp, video_bp, image_bp, asmr_bp
|
|
|
|
|
|
def create_app(config_name="development"):
|
|
app = Flask(__name__)
|
|
CORS(app)
|
|
app.config.from_object(DevelopmentConfig)
|
|
|
|
if config_name == 'production':
|
|
app.config.from_object(ProductionConfig)
|
|
elif config_name == 'testing':
|
|
app.config.from_object(TestingConfig)
|
|
else:
|
|
app.config.from_object(DevelopmentConfig)
|
|
|
|
|
|
db.init_app(app)
|
|
migrate.init_app(app, db)
|
|
|
|
app.register_blueprint(torrent_bp.bp, url_prefix='/api/torrent')
|
|
app.register_blueprint(book_bp.bp, url_prefix='/api/book')
|
|
app.register_blueprint(music_bp.bp, url_prefix='/api/music')
|
|
app.register_blueprint(file_bp.bp, url_prefix='/api/file')
|
|
app.register_blueprint(video_bp.bp, url_prefix='/api/video')
|
|
app.register_blueprint(image_bp.bp, url_prefix='/api/image')
|
|
app.register_blueprint(asmr_bp.bp, url_prefix='/api/asmr')
|
|
|
|
return app
|