Files
MiscCorpo/routes/scraperZLibraryRoute.py
hiep200311 adc1934e9c Refactor static serving: use Blueprint static_folder, inline header
- Disable Flask default /static/ folder (static_folder=None in app.py)
- Add headerRoute blueprint to serve views/header/ at /assets/header/
- Configure transcription and scraper blueprints with static_folder
  pointing to their respective views/ subfolders
- Inline header HTML directly in headerLoader.js (remove fetch call)
- Update all HTML templates to use new /assets/... URLs
2026-06-24 16:22:31 +07:00

30 lines
1.3 KiB
Python

# routes/scraperZLibraryRoute.py
from flask import Blueprint
from controllers.scraperZLibraryController import ScraperController
# Blueprint với static_folder trỏ vào views/scraperZLibraryPages
# → Flask serve CSS/JS qua URL /scraperZLibrary/assets/scraper/...
# Lưu ý: static_url_path chỉ cần phần sau /scraperZLibrary/ (url_prefix đã được thêm khi register)
scraperZLibraryRoute = Blueprint(
'scraperZLibrary',
__name__,
static_folder='../views/scraperZLibraryPages',
static_url_path='/assets/scraper',
)
# Define routes
scraperZLibraryRoute.route('/', methods=['GET'])(ScraperController.index)
scraperZLibraryRoute.route('/api/search', methods=['POST'])(ScraperController.search_books)
scraperZLibraryRoute.route('/api/download/txt', methods=['POST'])(ScraperController.download_txt)
scraperZLibraryRoute.route('/api/download/json', methods=['POST'])(ScraperController.download_json)
scraperZLibraryRoute.route('/api/download/books', methods=['POST'])(ScraperController.download_books_zip) # New route
scraperZLibraryRoute.add_url_rule(
'/api/download/stream',
view_func=ScraperController.download_books_stream,
methods=['POST'],
)
scraperZLibraryRoute.add_url_rule(
'/api/download/file/<token>',
view_func=ScraperController.fetch_stored_file,
methods=['GET'],
)