- 添加.gitignore和.flaskenv环境配置文件 - 创建Flask应用基础架构,包括models、services、utils模块 - 配置数据库模型User和Setting,集成SQLAlchemy和Alembic迁移 - 添加前端Vue项目结构,包含Element Plus组件库 - 配置前后端API路由和蓝prints模块 - 实现书籍下载服务BookService功能模块 - 添加代码规范配置.editorconfig、.oxfmtrc.json、.oxlintrc.json - 配置VSCode推荐插件和前端构建工具链 - 实现文件服务FileService和相关业务逻辑
92 lines
2.4 KiB
Python
92 lines
2.4 KiB
Python
from typing import List
|
|
from flask import Blueprint, jsonify, Response, current_app
|
|
from app.services import FileService, VideoService, TorrentService, BookService, ImageService, MusicService
|
|
|
|
bp = Blueprint("api", __name__)
|
|
|
|
|
|
@bp.route("/book/download")
|
|
def book_download():
|
|
book_object = BookService()
|
|
app = current_app._get_current_object()
|
|
|
|
def generate():
|
|
with app.app_context():
|
|
yield from book_object.book_download()
|
|
|
|
return Response(generate(), mimetype='text/event-stream')
|
|
|
|
@bp.route("/video/findDeduplication")
|
|
def video_find_deduplication():
|
|
video_object = VideoService(paths=[
|
|
"C:\\迅雷下载\\0_done",
|
|
"D:\\",
|
|
"E:\\",
|
|
"F:\\"
|
|
])
|
|
|
|
return jsonify({"code": 200, "message": video_object.find_deduplication()})
|
|
|
|
|
|
@bp.route('/video/deduplication')
|
|
def video_deduplication():
|
|
video_object = VideoService(paths=[
|
|
"C:\\迅雷下载\\0_done",
|
|
"D:\\",
|
|
"E:\\",
|
|
"F:\\"
|
|
])
|
|
|
|
return jsonify({"code": 200, "message": video_object.deduplication()})
|
|
|
|
|
|
@bp.route("/video/hasTorrent")
|
|
def video_has_torrent():
|
|
torrent_obj = TorrentService(["E:\\"])
|
|
return jsonify({"code": 200, "message": torrent_obj.has_torrent()})
|
|
|
|
|
|
@bp.route('/files/rename')
|
|
def files_rename():
|
|
paths: List[str] = [
|
|
"C:\\迅雷下载\\0_done",
|
|
"C:\\Users\\Localhost\\Desktop\\BT",
|
|
]
|
|
|
|
file_object = FileService(paths)
|
|
return jsonify({"code": 200, "message": file_object.rename()})
|
|
|
|
|
|
@bp.route('/torrent/deduplication')
|
|
def torrent_deduplication():
|
|
torrent_object = TorrentService(["C:\\Users\\Localhost\\Desktop\\BT"])
|
|
return jsonify({"code": 200, "message": torrent_object.deduplication()})
|
|
|
|
|
|
@bp.route("/image/export")
|
|
def image_export():
|
|
image_object = ImageService()
|
|
|
|
def generate():
|
|
yield from image_object.export()
|
|
|
|
return Response(generate(), mimetype='text/event-stream')
|
|
|
|
|
|
@bp.route("/image/hasTorrent")
|
|
def image_has_torrent():
|
|
torrent_obj = TorrentService(["C:\\Users\\Localhost\\Desktop\\Images"])
|
|
return jsonify({"code": 200, "message": torrent_obj.has_torrent()})
|
|
|
|
|
|
@bp.route("/music/rename")
|
|
def music_rename():
|
|
music_object = MusicService()
|
|
return jsonify({"code": 200, "message": music_object.rename()})
|
|
|
|
@bp.route("/torrent/statistics")
|
|
def torrent_statistics():
|
|
torrent_object = TorrentService(["C:\\Users\\Localhost\\Desktop\\BT"])
|
|
return jsonify({"code": 200, "message": torrent_object.statistics()})
|
|
|